两张表查询

[复制链接]
查看11 | 回复2 | 2009-3-2 15:37:48 | 显示全部楼层 |阅读模式
select a from table1where b in (select b from table2 )
select a from table1where b in (select b from table3)

两张表A字段内容有重复,如何将A字段内容对比
不是去重``是要找到那些内容是重复的```

回复

使用道具 举报

千问 | 2009-3-2 15:37:48 | 显示全部楼层
SQL2005用except/intersect比较比较存在重复select a from table1 where b in (select b from table2 ) intersectselect a from table1 where b in (select b from table3)orselectafrom table1where b in(select b from(select distinct b from table2 union all select distinct b from table3)t group by b having count(*)>1)...
回复

使用道具 举报

千问 | 2009-3-2 15:37:48 | 显示全部楼层
----a在两个查询都存在用下面的select a from (select a from table1 where b in (select b from table2)) c, (select a from table1 where b in (select b from table3)) d where c.a=d.a---...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行