[thelist] SQL subqueries in mySQL 3.23.54

john at johnallsopp.co.uk john at johnallsopp.co.uk
Mon Mar 1 15:25:20 CST 2004


I seem to remember that SQL subqueries aren't necessary because there's an
alternative structure you can use. I think mySQL 3.23.45 can't do
subqueries, so can anyone remember the alternative method?

In detail, should you wish it, I've three tables joined by an id. I want
to select all the records from table A where the number of matching ids in
table B is greater than the number of matching ids in table C.

That's something like this I think, except I can't do the subquery:

SELECT * FROM A, B, C where A.id = B.id and A.id = C.id and (select
count(*) from A, B where A.id = B.id) > (select count(*) from A, C where
A.id = C.id)

All help appreciated as always :-)


More information about the thelist mailing list