sql group_concat函数
用法相当于聚合函数,在分组时使用,将同一组的某个字段用concat拼接起来,比如表中有省份和城市字段,页面要二级联动的效果
select provinceName,group_concat(cityName) AS cityName from tablename
where provinceName is not null and cityName is not null
group by provinceName
==> Preparing: select provinceName,group_concat(cityName) AS cityName from tablename where provinceName is not null and cityName is not null group by provinceName
==> Parameters:
<== Columns: provinceName, cityName
<== Row: 江苏省, 淮安市,昆山市,徐州市
<== Row: 河北省, 石家庄市,廊坊市,保定市
<== Row: 河南省, 郑州市,鹤壁市
<== Total: 3
浙公网安备 33010602011771号