1,把表中某一列的内容合并为一行
select province,CONCAT(‘[\"全部\",\"‘,GROUP_CONCAT(city ORDER BY cityID separator ‘\"\,\"‘),‘\"]‘) as group1 from hat_city a LEFT JOIN hat_province b on a.father=b. provinceID GROUP BY father
ORDER BY cityID:根据指定字段排序,再合并
separator:指定分隔符,本文分隔符为(",")
时间: 2024-10-26 18:47:11