Hi.
I have six tables stored in a database. Each of the six tables contains an column called "id".
I want to do a MySQL query that selects instances of id that are present in all six tables. So, if the number "3" happens to be present in all of the id columns in all of the six tables, then I would expect my query to return the number 3. Conversely, If the number '5' only appears in 4 of the tables, then I do not want the number 5 to be returned.
The funny thing is, I already know an SQL query for doing this. The trouble is, it's a very VERY long query and I was just wondering if there was a quicker way. It would save me a lot of heartache if there was.
Here is the MySQL query I've been using so far (let's assume that the tables are called "tableA, tableB, tableC...' and so on).
Select tableA.id, tableB.id, tableC.id, tableD.id, tableE.id, tableF.id
from tableA, tableB, tableC, tableD, tableE, tableF
where tableA.id=tableB.id
AND tableA.id=tableC.id
AND tableA.id=tableD.id
AND tableA.id=tableE.id
AND tableA.id=tableF.id;
The above command works, but as you can see, it is a total eyesore. It would really help me if there was a quicker way of doing this. Thanks