簡單的問題一個SELECT:CONCAT組中的另一SELECT
有2個表:
流派[名稱,songID]
宋[ID,標題,用戶ID,狀態]
SELECT id,name,title,userID,status FROM songs INNER JOIN genre ON song.id = genre.songID ORDER BY id ASC;
什麼是查詢從
+----+-------------+----------------------+--------+--------+
| id | genre.name | song.title | userID | status |
+----+-------------+----------------------+--------+--------+
| 1 | tech | Feel it all | 1 | 1 |
| 2 | tech | Tester | 1 | 1 |
| 3 | music | Sejujurnya | 1 | 1 |
| 4 | music | Not Done | 1 | 1 |
| 5 | life | Cinta | 1 | 1 |
| 6 | life | Feel it all | 1 | 1 |
| 7 | life | Not Done | 1 | 1 |
| 8 | truth | Tester | 1 | 1 |
| 9 | tree | Tester | 1 | 1 |
| 10 | climb | Tester | 1 | 1 |
+----+-------------+----------------------+--------+--------+
到
+----+-------------+---------------------------------+--------+--------+
| id | genre.name | song.title | userID | status |
+----+-------------+---------------------------------+--------+--------+
| 1 | tech | Feel it all,Tester | 1 | 1 |
| 2 | music | Sejujurnya, Not Done | 1 | 1 |
| 3 | life | Cinta, Feel it all, Note Done | 1 | 1 |
| 4 | truth | Tester | 1 | 1 |
| 5 | tree | Tester | 1 | 1 |
| 6 | climb | Tester | 1 | 1 |
+----+-------------+---------------------------------+--------+--------+
感謝
可能的重複http://stackoverflow.com/questions/4650744/mysql-multiple-row-to-single-row –
我想我看到一個模式,來自同一流派的標題是內爆的,但然後'暗夜'和'布卡'有什麼關係?他們甚至不在原來的桌子上。 –
查看MySQL中的[GROUP_CONCAT-function](http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat)。 @Declan_K:你的鏈接是針對SQL服務器的,稍有不同。 –