我有以下查询:
select card.id as id, photo.image as photo
from card
left outer join card_image as photo on (photo.card=card.id)
返回
+----+-------+
| id | photo |
+----+-------+
| 1 | 2 |
| 1 | 3 |
| 1 | 4 |
| 2 | 5 |
| 2 | 6 |
+----+-------+
如果我将photo.image作为照片更改为group_concat(photo.image)作为照片,我会得到以下结果
+----+---------------+
| id | photo |
+----+---------------+
| 1 | 2,3,4,5,6 |
+----+---------------+
但我的期望是
+----+-----------+
| id | photo |
+----+-----------+
| 1 | 2,3,4 |
| 2 | 5,6 |
+----+-----------+
即我希望通过id获得每张卡片的一组照片