select dept_no,
group_concat(emp_no) as employees
from dept_emp
group by
dept_no;
GROUP_CONCAT([DISTINCT] column_name [ORDER BY column_name [ASC|DESC]] [SEPARATOR separator])
参数说明
DISTINCT :可选关键字,用于去除重复值。
column_name :要拼接的列名。
ORDER BY :可选子句,用于指定拼接时的排序规则。
SEPARATOR :可选参数,用于指定拼接时的分隔符,默认分隔符是逗号(,)。



京公网安备 11010502036488号