zyanfei
11/6/2018 - 12:51 AM

group_concat用法

情景是某些情况下group_concat数据会变换,在里面加上order by 就解决了~

SELECT
	student_id,
	GROUP_CONCAT(
		courses_id
		ORDER BY
			courses_id DESC
	) AS courses
FROM
	student_courses
WHERE
	student_id = 2
GROUP BY
	student_id;