distinct关键字
查询结果distinct不起作用,无效
可能原因:结果中是根据你查询的所有字段进行去重,只要某个字段不一样就视为两条数据
场景:
查询的字段有多个,但是只想根据某个或某几个字段进行去重
解决办法:
利用group_concat(distinct name) 和group by 结合即可
select *,group_concat(distinct name) from table_name group by name
distinct关键字
查询结果distinct不起作用,无效
可能原因:结果中是根据你查询的所有字段进行去重,只要某个字段不一样就视为两条数据
场景:
查询的字段有多个,但是只想根据某个或某几个字段进行去重
解决办法:
利用group_concat(distinct name) 和group by 结合即可
select *,group_concat(distinct name) from table_name group by name