-- 1,2,3,4,5
SELECT * FROM dbo.tblTable01

-- 1,2,3
SELECT * FROM dbo.tblTable02

--1,2,3
SELECT
	*
FROM
	dbo.tblTable01 t1
WHERE
	EXISTS
	( 
		SELECT t2.Id FROM dbo.tblTable02 t2 WHERE t1.Id = t2.Id 
	)

-- 4,5
SELECT
	*
FROM
	dbo.tblTable01 t1
WHERE
	NOT EXISTS
	( 
		SELECT t2.Id FROM dbo.tblTable02 t2 WHERE t1.Id = t2.Id 
	)
Last modified: November 11, 2019

Author

Comments

Write a Reply or Comment