SQLTeam.com | Weblogs | Forums

T-SQL IN Statement Need Help


I have a standard Query and in the query I want to filter out using an IN statement with two rules...I attempted to google this to no avail and it's the first time I have needed to do this. I want to filter out any results where the 'Id' and 'Amount' fields equal the same fields in the main query. If there is a better way I am up for learning as I just started SQL this year. ...Normally I would so something like

(Table1.Id NOT IN (
SELECT Table2.Id
FROM Table2
(Rules here)


SELECT t1.Id, t1.Amount, ...
FROM Table1 t1
WHERE NOT EXISTS(SELECT 1 FROM Table2 t2 WHERE t2.Id = t1.Id AND t2.Amount = t1.Amount)