SQL Query to use IN and Where clause

Using the IN keyword, we can construct a more compact statement,where the set of possible values are enclosed in parentheses and separated by commas.

Each row of Entry is investigated, and if TourID is one of the values in the set, then the WHERE condition is true, and that row will be returned.

Using IN keyword

SELECT e.MemberID
FROM Entry e
WHERE e.TourID IN (36, 38, 40)

Using NOT IN keyword

SELECT e.MemberID
FROM Entry e
WHERE e.TourID NOT IN (36, 38, 40)
 
Conclusion
The above examples useful to use IN and NOT IN key words in your SQL.

Comments

Popular posts from this blog

Top myths for NULL value in SQL Queries