查找表A中不在表B中的记录 [英] find records in Table A which is not in Table B

查看:103
本文介绍了查找表A中不在表B中的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

There are two same structure table in Database i.e. Table A and B. Table A contains 100 records and Table B contain 50 records which is already in Table A.

Write a sql query find records in Table A which is not in Table B (don't use "in" operator and subquery)  

推荐答案

您好b $ b

希望这可能帮助



Hi
Hope this may help

select * from dbo.TableA A FULL OUTER JOIN dbo.TableB B ON A.ColName=B.ColName where B.ColName is null


< br $> b $ b

请看下面的查询...



Hi,

Look at below query also...

--Take a note...your selected columns in both tables should be same, here i am assuming as per your input
SELECT * from A
MINUS
SELECT * FROM B
--if require put where clause





希望这会对你有帮助。





干杯



Hope this will help you.


Cheers


SELECT  a.*
FROM    Table1 A
        LEFT JOIN Table2 B
            ON A.name = B.name 
WHERE   B.Name IS NULL





希望这可以帮助你:)



Hope this helps you :)


这篇关于查找表A中不在表B中的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆