sql语句查询去除重复不用distinct用having
id       name     sex      add      mobile
1	2	2	2	2
2	2	2	3	4
3	4	3	4	5
根据name去掉重复只留一条查询结果如下
id       name     sex      add      mobile
1	2	2	2	2
3	4	3	4	5
或者
id       name     sex      add      mobile
2	2	2	3	4
3	4	3	4	5
------解决方案--------------------
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
--or
select * from tb  t where id=(select max(id)from tb where name=t.name )