简体   繁体   中英

SQL Select where two values not in the same row of another table

桌子 I need a select that return the values from T2.C from rows which combination of T2.A and T2.B doesn't exist in T1.

Something like:

select C from T2 where A,B not in (select A,B from T1)

Results from example must be:

C
--
y
z

Do you mean like

SELECT T2.*
FROM T2
LEFT OUTER JOIN T1
 ON T2.ColumnA = T1.ColumnA
 AND T2.ColumnB = T1.ColumnB
WHERE T1.ColumnA IS NULL;

If you do an outer join, you can easily notice a lack of a match (via nulls).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM