Consider two tables Table_A (EmployeeID, Firstname, Lastname, Designation, Address) and Table_B (EmployeeID, Firstname, Lastname, Designation, Address).
Table_A contains 10,000 rows and Table_B contains 5000 rows. I want to get the rows from Table_A which are not present in Table_B:
SELECT * FROM Table_A
WHERE NOT EXISTS (SELECT 'X' FROM Table_B WHERE Table_B.EmployeeID = Table_A.EmployeeID)
I want to get the rows from Table_A which are present in Table_B:
SELECT * FROM Table_A
WHERE EXISTS (SELECT 'X' FROM Table_B WHERE Table_B.EmployeeID = Table_A.EmployeeID)
Table_A contains 10,000 rows and Table_B contains 5000 rows. I want to get the rows from Table_A which are not present in Table_B:
SELECT * FROM Table_A
WHERE NOT EXISTS (SELECT 'X' FROM Table_B WHERE Table_B.EmployeeID = Table_A.EmployeeID)
I want to get the rows from Table_A which are present in Table_B:
SELECT * FROM Table_A
WHERE EXISTS (SELECT 'X' FROM Table_B WHERE Table_B.EmployeeID = Table_A.EmployeeID)
HI Mahadevan
ReplyDeleteI Think We Can Use Except Function For First One And Intersect For Second One
as
1ans):- Select * from a except Select * from b
2ans):- Select * from a Intersect Select * from b