sql语句查询去除重复不用distinct用having解决办法

sql语句查询去除重复不用distinct用havingidnamesexaddmobile122222223434345根据name去掉重复只留一条查

sql语句查询去除重复不用distinct用having
id name sex add mobile
12222
22234
34345


根据name去掉重复只留一条查询结果如下
id name sex add mobile
12222
34345
或者
id name sex add mobile
22234
34345


[解决办法]
select tb.* from tb,(
select MAX(id) as id from tb 
group by tb.name)tb2
where tb.id=tb2.id
[解决办法]

SQL code
select * from tb  t where not exists(select 1 from tb where name=t.name and id>t.id)
[解决办法]
SQL code
--orselect * from tb  t where id=(select max(id)from tb where name=t.name )