Computer Guy
asked on
MySQL Syntax
Hi,
I have this:
Group, Genre
General, 80s
General, 90s
Electronic, Techno
Electronic, House
How can I display it like this:
General 80s
90s
Electronic
Techno
House
I have this:
Group, Genre
General, 80s
General, 90s
Electronic, Techno
Electronic, House
How can I display it like this:
General 80s
90s
Electronic
Techno
House
Display issues (e.g. not repeating a category name) are handled in your front end code (e.g. PHP), not in the MySQL query.
Hi!
This is what you are looking for.
If the columns of the table is Group and Genre then
Note that the word group is a reserved word in all dbms systems so using that in a table or view could lead to parsing errors when executing sql statements.
http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
Regards,
Tomas Helgi
This is what you are looking for.
If the columns of the table is Group and Genre then
select `group`, group_concat(genre, ',' )
from table
group by `group`
Note that the word group is a reserved word in all dbms systems so using that in a table or view could lead to parsing errors when executing sql statements.
http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
Regards,
Tomas Helgi
ASKER
Hi, group_concat(genre, ',' ) puts them next to eachother, how can I make them each on their own line?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.