日期:2014-05-18  浏览次数:20491 次

用left outer join如何查询出表1和表2中不相等的记录
用left outer join如何查询出表1和表2中不相等的记录
比如表1 有 1、2、3 表2有1、2
如果用用left outer join语句体现表1和表2中不相等的记录?

------解决方案--------------------

SQL code
select * from 1 join 2 on 1.字段名<>2.字段名

------解决方案--------------------
SQL code

select a.a,b.b from a left outer join b on a.a=b.b where b.b is null

------解决方案--------------------
不能用连接,用:
select * from 表2 a where not exists(select 1 from 表1 where id=a.id)
select * from 表1 a where not exists(select 1 from 表2 where id=a.id)
------解决方案--------------------
用子查询吧