mysql - Display one row for value with multiple categories -


i have table named games. each game belongs 1 or more categories. have query uses group category_id returns not desired result. example below, cod belongs 3 category_id query shows specific game , omits other games same category_id. how can achieve below desired query?

query:

select * games group category_id 

desired result:

+----------------+--------------------------+ |   game_name    |       category_id        | +----------------+--------------------------+ | cod            | adventure, fighting, fps | | tekken         | fighting                 | | need speed | racing                   | +----------------+--------------------------+ 

sqlfiddle

use group_concat function

select  game_name, group_concat(category_id) categories   games  group   game_name; 

good luck!


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -