[thelist] SQL subqueries in mySQL 3.23.54

Tab Alleman Tab.Alleman at MetroGuide.com
Mon Mar 1 15:50:06 CST 2004


john at johnallsopp.co.uk wrote:

> 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)

Oooh, a puzzle!  Let's see, 

SELECT * FROM A
INNER JOIN B ON A.id=B.id
INNER JOIN C ON A.id=C.id
HAVING COUNT(B.id) > COUNT(C.id)


Does that do it?


More information about the thelist mailing list