Skip to toolbar

Forum

How to find only no...
 
Notifications
Clear all

How to find only non matching records from both tables?  


vinodkrsetty
Posts: 15
Admin
(@vinodkrsetty)
Member
Joined: 1 year ago

Can anyone answer this question How to find only nonmatching records from both tables?

2 Replies
VK
Posts: 17
 VK
(@vinodkrsetty5895)
Active Member
Joined: 4 months ago

You can try the below query. Just change the table names and column names as per your requirement.

SELECT B.CountryID
FROM TableB AS B
LEFT JOIN TableA AS A ON A.CountryID = B.CountryID
WHERE A.CountryID IS NULL

Reply
Siva Kumar
Posts: 36
 Siva Kumar
Guest
(@Siva Kumar)
Joined: 4 months ago

 

I will tell you the two ways how you can acheive this.

Consider the below two tables.

Table 1:

EmpID        ACT_no      NAME

1                     19              ddd
2                     20              eee
3                     21               fff
4                     22              adada
5                     23              mmmmm
6                     24              yyyy

 

Table 2:

sr no             ACT_no      Balance

1                    19               4000
2                    20               5675
3                    21               3300

Query 1

select t1.EmpID,t1.ACT_no,t1.Name from table1 t1
left outer join table2 t2 on t1.Act_no_no = t2.Act_no
where
t2.EmpIdD is null

Query 2

select t1.* from table1 t1 where

not exists (

select 1 from table2 t2
where t1.ACT_no=t2.ACT_no
)

Reply

Leave a reply

Author Name

Author Email

Title *

Maximum allowed file size is 10MB

 
Preview 0 Revisions Saved
Share: