Wednesday, March 21, 2012

Need count and subselects

Hello,
i use mysql 4.0.20 and have the following problem:
I have a column with names and want to extract all names which are lets say 3 times in this column. See

Names
foo
bar
bla
foo
bla
bla
foo

In this case mysql shoud output foo and bla, but how to do this??
I tried some combinations of count and something like subselects, but no success.

Could anybody help me please? It drives me crazy.
Thanks, b52hmm, does mysql support having?

group by names
having count(*) = 3|||yea it does,
i will give it a try, but not sure to get it working.

Thanks, bye, b52|||YES it works! :D :D
SELECT KNAME FROM AUFTRAG LEFT JOIN KUNDE ON KNR=AKNR GROUP by KNAME HAVING COUNT(*) =3

Thank you :) , bye, b52sql

No comments:

Post a Comment