I would like to accomplish this within one query if at all possible. I know I could query the products table for a list of unique category_slugs and then perform queries on each of those, but… bleh.
Tables
products
————
category_slug VARCHARcategories
—————
slug VARCHAR
title VARCHAR
Goal:
I would like to select categories.slug, categories.title from categories WHERE products.category_slug is UNIQUE.
I’m pretty sure that statement can lead me to a syntactically correct SQL statement, I have all the keywords in there.
I was giving this a go, but my subquery returns more than one row (as it should):
SELECT categories.slug, categories.title FROM categories JOIN products WHERE products.category_slug = ( SELECT DISTINCT category_slug FROM products )
Ideas?
