[thelist] SQL subqueries in mySQL 3.23.54

Tab Alleman Tab.Alleman at MetroGuide.com
Tue Mar 2 08:20:58 CST 2004


Joshua Olson wrote:
>> 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?
> 
> Tab,
> 
> You can't have a HAVING clause without a GROUP BY clause... and you
> can't have a SELECT * with a GROUP BY clause...  so, this won't work.

Hmmm, what about UNION-ing a SELECT Grouped by B.id with a SELECT
Grouped by C.id?  I've never needed to use UNION so I'm not sure of the
syntax.


More information about the thelist mailing list