Welcome Guest, Not a member yet? Register   Sign In
Only display populated categories
#3

[eluser]chipp[/eluser]
[quote author="GrahamDj28" date="1336143695"]Here is a query that could help you.

Code:
SELECT c.*, i.*
FROM category AS c
LEFT JOIN item AS i ON i.cat_id = c.id

This should return only categories that have items, and it will also contain the items. If you only want the categories, then remove i.* from the select[/quote]

Thank you for the quick response. So once I have retreived my query results I could have something like.

Category Item
1 1
1 2
2 3
3 4
3 5
3 6

This would would give me duplicate cat_id's. How can I remove duplicates to retrieve my array of populated cat_id's?


Messages In This Thread
Only display populated categories - by El Forum - 05-04-2012, 07:51 AM
Only display populated categories - by El Forum - 05-04-2012, 08:01 AM
Only display populated categories - by El Forum - 05-04-2012, 08:07 AM
Only display populated categories - by El Forum - 05-04-2012, 08:29 AM
Only display populated categories - by El Forum - 05-04-2012, 09:03 AM
Only display populated categories - by El Forum - 05-04-2012, 09:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB