九里香适合在屋内养吗:帮我看看SQL语句,重复记录只选一条

来源:百度文库 编辑:杭州交通信息网 时间:2024/05/04 16:55:39
我想选择数据表里的记录,当字段A有重复的时候,A只显示出一条记录。
这个SQL怎么写啊?

我要显示数据表的全部字段。
可是我要显示全部字段啊

小问题
语法如下:
select distinct “A字段名” from tablename

试试吧!

假设id是主键

select * from 表 where id in (select max(id) from 表 group by A)

用distinct关键字
select distinct [字段名] from tablename

select distinct * from 表 where 条件

select * from tablename where 条件 group by A

select distinct A from tablename