[thelist] mysql - selecting based on count of key
Keith Gaughan
keith at digital-crew.com
Mon May 9 16:54:15 CDT 2005
David Siedband wrote:
> 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?
You need to do a GROUP BY on ProjID.
More information about the thelist
mailing list