ORACLE:
select * from scott.stu
union (all)重复的去掉[intersect把相同的取出来][minus显示不相同的数]
select * from stu
-----------------------------------------------------------------
显示相同的数据
select name from stu intersect select name from stu1;
删除重复记录
Delete from tablename where id not in (select max(id) from tablename group by col1,col2,...)
distinct 是对所有查询字段(一条记录一条记录)比较,相同只则保留一条
请关注 GROUP BY 子句语法
如果你想过滤全表就写 select distinct * from A
如果要过滤几个字段就写 select distinct name,sex from A
select DISTINCT name,sex from 表A 只会过滤掉name 和sex 都重复的数据。
多字段的话要用group by
select name,sex from A group by name,sex