I am using SQL Server 2014 and I have a table (t1) in my database which contains a list of numbers (n1 to n6). An extract is given below:
Id n1 n2 n3 n4 n5 n6
100 3 10 26 31 35 39
101 1 3 11 22 36 40
102 10 19 20 30 39 40
103 6 12 25 27 28 33
...
Assuming I want to filter out this table by excluding rows where numbers 3 and 19 exist, my filtering codes would look like this:
Select * from t1
WHERE [n1] not in (3,19)
AND [n2] not in (3,19)
AND [n3] not in (3,19)
AND [n4] not in (3,19)
AND [n5] not in (3,19)
AND [n6] not in (3,19)
Expected Output:
Id n1 n2 n3 n4 n5 n6
103 6 12 25 27 28 33
...
Is there a more efficient way to write my filters?