问题:我想将子查询的结果合并为一个文本字段,结果用逗号(或任何符号)分隔到主查询的结果中。
例子:
表格1:
+----------+---------+
| user_ID | user |
+----------+---------+
| 1 | Smith |
+----------+---------+
| 2 | Jones |
+----------+---------+
表格1:
+----------+---------+
| user_ID | roles |
+----------+---------+
| 1 | Admin |
+----------+---------+
| 2 | Staff |
+----------+---------+
| 2 | Admin |
+----------+---------+
| 2 | Super |
+----------+---------+
| 1 | Other |
+----------+---------+
所以结果是:
+----------+---------+----------------------------+
| user_ID | user | roles |
+----------+---------+----------------------------+
| 1 | Smith | Admin, Other |
+----------+---------+----------------------------+
| 2 | Jones | Staff, Admin, Super |
+----------+---------+----------------------------+
任何帮助将不胜感激。