Page 1 of 1

Getting duplicates returned from db

Posted: Fri Dec 30, 2005 11:37 am
by Luke
I am making a new directory and I now have 3 tables set up...

directory - contains all info relating to the company listed
cat - contains all available categories
dircat - contains information relating the two above tables to eachother

Now I've created this query to select only categories that have one or more listings in them, but it returns duplicates of the same category (because there are more than one listing with that category) How would I make mysql not return duplicates of the same category?

Code: Select all

SELECT cat.cat_id, cat.cat_category
FROM cat, dircat
WHERE cat.cat_id = dircat.cat_id
If there is no way to make mysql return this... is there a convenient php function that will find all duplicate values and delete them from the return array?

Posted: Fri Dec 30, 2005 12:41 pm
by timvw
group by category

Posted: Fri Dec 30, 2005 1:06 pm
by Luke
huh?

Posted: Fri Dec 30, 2005 8:18 pm
by mickd