Web applications need to allow end users to select groups of rows by project, product or something interesting. So the best way to do that is to ask the database for a list of unique groups. Unfortunately, MySQL syntax doesn't have one, and the journey can lead to some commands that are downright scary for a simple database kind of thing to do.
SELECT * , count( `product` )
FROM `results`
GROUP BY `product`
HAVING count( `product` ) >=1
LIMIT 0 , 30
and bug the mysql people to add:
SELECT * FROM `results` WHERE DISTINCT `product` ;)
It works very good. Good ideea this post. Thanks, I apreciated it a lot
ReplyDeleteThx for this script. I am looking for this one. BEST
ReplyDeleteGreat man, it helped me a lot !! amd you're right!!: mysql people have to add:
ReplyDeleteSELECT * FROM `results` WHERE DISTINCT `product`