表:user。字段:ID ,name ,age。需要去重的字段 age
SQL:
一、使用 group_concat函数
select ID,name,group_concat(distinct age) from user group by age
二、使用count函数
select ID,name,count(distinct age) from user group by age
注意:后面别忘记加上 group by 这个去重的字段
表:user。字段:ID ,name ,age。需要去重的字段 age
SQL:
一、使用 group_concat函数
select ID,name,group_concat(distinct age) from user group by age
二、使用count函数
select ID,name,count(distinct age) from user group by age
注意:后面别忘记加上 group by 这个去重的字段