SQL 去重

select name, picture_url from table_name
where name = 'ABC' or name = 'DEF' 

想对name去重,而不对picture_url去重,picture_url随便取一个就行

如果写成

select distinct name, picture_url from table_name
where name = 'ABC' or name = 'DEF' 

就是对name+picture_url去重

解决方案:

select name, max(picture_url) from table_name
where name = 'ABC' or name = 'DEF'
group by name 
©️2020 CSDN 皮肤主题: 创作都市 设计师:CSDN官方博客 返回首页