I have three tables (iwc, sensors and valves) and I want to get the number of different suppliers from these three tables. If I had just one table, I know I'd do this:
Code:
select distinct(column) from table"
, but how would I go about doing this with three? Is it even possible?
(btw, I'm using an access database)
Thanks in advance (although I'll probably say thanks again at the end )
Ok, this shouldnt be too hard to achieve with some nifty SQL work.
SQL statement:
PHP Code:
SELECT iwc.suppliers, sensors.suppliers, valves.suppliers FROM iwc, sensors, valves
We could also use the INNER JOIN statement to try and make a match, but that is not necessary here. Also, you will have to change the field name to suit.
Sorry, I haven't made myself clear. I need to get a list of all suppliers that appear, but for each one only to appear once, no matter how many times they appear in each table.
And changing the column name isn't really a valid option since this is quite a large site and I am only performing this particular search on one page.
Oops, sorry, my bad. I have a further problem in that the three columns do not have the same name (I did not start this project, only came in about half way through and by that time it was too late). I'm now assuming that this will not be possible.
I'm not up to scratch on sql server (the only reason im using it is because some queries are v big and can't be run using access - it complains), but I'm using ADO to query the db, not any gui interface.
Bookmarks