Mysql
 sql >> Database >  >> RDS >> Mysql

Output elenco di record MySQL, raggruppati per categoria?

Prova questo:

SELECT category, GROUP_CONCAT(ProdName) as Product
FROM recipes
GROUP BY category
ORDER BY category, ProdName ASC

Risultato:

CATEGORY     PRODUCT
----------------------------------------------------------
Mustards     Hot Mustard,Horseradish Mustard,Honey Mustard
Sauces       Tomato Sauce,Barbeque Sauce

Guarda questo SQLFiddle