sreeprasad
sreeprasad

Reputation: 3260

How can I compare 2 columns in 2 tables to check for UNEQUAL values

I have a table say Table 1 with column A with values {22,18,17} and another table Table 2 with column B with values {18,22} when I do a query like

select * from Table 1 where column A not in (select column B in Table 2). 

This gives me 3 rows {22,18,17}

I want only 17 as output.

I am newbie to SQL can anyone help me

Upvotes: 0

Views: 1762

Answers (1)

TrevDev
TrevDev

Reputation: 1106

SELECT * FROM Table1 as T1
LEFT JOIN Table2 as T2 on T1.ColumnA = T2.ColumnB
WHERE T2.T2ID IS NULL

Upvotes: 2

Related Questions