MYSQL字段值去重

1.根据名称分组去重,并查询记录ID

select max(id) from T_TABLE GROUP BY name

2.根据ID获取记录

select * from T_TABLE where ID in ( select max(id) from T_TABLE GROUP BY name )

posted @ 2019-11-18 16:20  bud  阅读(495)  评论(0编辑  收藏  举报