SQL 串接結果 (mySQL only)

情境: 想要做到取出的資料如下所示

rno   kno

1     2,3,4

2     2,4,6

最後找到可以用的:

SELECT rno, GROUP_CONCAT(kno order by kno asc) AS nkno FROM rkr WHERE rno IN ( SELECT rno FROM rkr ) GROUP BY rno;

類似的實作方式在 oracle 是用 COLLECT 的樣子, 參考 oracle實現mysql的group_concat功能

Leave a Reply

Your email address will not be published. Required fields are marked *