我有以下表格,我想在一行中显示一个游戏的所有类型。有一个game
表,其中包含GameID和GameTitle:
流派表
GenreID Genre_Name
----------------------
1 Action
2 Third Person
3 Open World
game_genre table
GameGameID GenreGenreID
-------------------------
197 1
197 2
197 3
这是我得到的结果:
GameID GameTitle Genre
-------------------------------------
197 Watch Dogs Third Person
197 Watch Dogs Action
197 Watch Dogs Open World
查询:
SELECT *, GROUP_CONCAT(Genre_Name)
FROM game
JOIN game_genre ON game.GameID = game_genre.GameGameID
JOIN genre ON game_genre.GenreGenreID = genre.GenreID`
如何让表格看起来像这样?
GameID GameTitle Genre
--------------------------------------------------------------------
197 Watch Dogs Third Person, Action, Open World