[thelist] mysql - selecting based on count of key

Joshua Olson joshua at waetech.com
Mon May 9 17:31:04 CDT 2005


> -----Original Message-----
> From: David Siedband
> Sent: Monday, May 09, 2005 5:41 PM
> 
> I have an index table that linkes to Projects and Documents based on 
> foreign keys: ProjID , DocID, and I want to find documents that are 
> linked to more than a threshold number of projects.
> 
> trying some vartions on this...
> 
>     select distinct ProjID
>     from ProjectDocuments
>     where Count(DocID) > '3'
> 
> Can this be done in a single query?

Becomes:

select ProjID
from ProjectDocuments
GROUP BY ProjID
HAVING Count(*) > 3

<><><><><><><><><><>
Joshua L. Olson
WAE Tech Inc.
http://www.waetech.com/
Phone: 706.210.0168 

Monitor bandwidth usage on IIS6 in real-time:
http://www.waetech.com/services/iisbm/




More information about the thelist mailing list