+ -
当前位置:首页 → 问答吧 → 去掉交换重复的数据

去掉交换重复的数据

时间:2011-10-14

来源:互联网

比如有两列
id1 id2
1 2
1 3
2 1
3 1

怎么得到

id1 id2
1 2
1 3

作者: tianzero   发布时间: 2011-10-14

详细说明,有重复取最小 ?

作者: WWWWA   发布时间: 2011-10-14

SQL code
select *
from table1 a
where not Exists (select 1 from table1 Where id1=a.id2 and id2=a.id1 and id1<id2)

作者: ACMAIN_CHM   发布时间: 2011-10-14

不知所云~~查询规则说下吗

作者: zhaoyun0209   发布时间: 2011-10-14

应该想表达 有2列,只有是相同的,不管是第1列在前 还是第2在前,只取一条

作者: tangyu477   发布时间: 2011-10-14

加入自增字段ID
select *
from ttj a
where not Exists (select 1 from ttj Where id1=a.id2 and id2=a.id1 and a.id>id)

作者: WWWWA   发布时间: 2011-10-14

相关阅读 更多