Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to display records over a certain number?

Status
Not open for further replies.

james0816

Programmer
Jan 9, 2003
295
US
think my brain is now officially fried as i can not come up with this query....

i want to display records from my table where the record count is say over 5.

real simple...two columns a and b. 10 records in the table.

a
1
1
1
2
3
2
3
1
1
1

i only want to display those records from column a when there are five or more records. it is not a set field so i can't just say when column.a=1.

 
select *
from yourtable
where a in
( select a
from yourtable
group by a
having count(a) >= 5 );

That required a version of mysql that supports nested queries (>4.1?).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top