I am trying to run a query given three tables.
DECLARE @TABLE1 TABLE (ID CHAR(2))
DECLARE @TABLE2 TABLE (ID CHAR(2))
DECLARE @TABLE3 TABLE (ID CHAR(2))
INSERT INTO @TABLE1 VALUES('1')
INSERT INTO @TABLE1 VALUES('2')
INSERT INTO @TABLE2 VALUES('1')
--NOTHING in TABLE3
I Need to get only the values that are present and ignore the null table. This doesn't work since TABLE3 has no values.
SELECT ID
FROM @TABLE1
INTERSECT
SELECT ID
FROM @TABLE2
INTERSECT
SELECT ID
FROM @TABLE3
**Result should be 1**
How do I ignore the any table if it's null but keep the other values?