In this post, we want to discuss a nice function to use multiple columns for NOT IN in SQL Server. Before we get started, if you want to know about random number generators, please go through the following article: Random Number Generator Script – SQL Query.
Let’s Start. I want to select all records from a table FRIEND where the values in columns f1 and f2 has no matching tuple for the columns l1 and l2 in table LIKES.
SELECT * FROM FRIEND F
WHERE not exists
SELECT 1 FROM LIKES L WHERE F.f1 = L.l1 and F.f2 = L.l2
Can you use multiple columns for NOT IN
The article was published on April 7, 2016 @ 11:11 AM