PostgreSQL SyntaxLesson 27Free preview
PostgreSQL IN
This lesson is part of PostgreSQL · All levels
Summary
The IN operator checks whether a value is included in a given value list or in the result of a subquery. Logically IN is equivalent to the OR condition series, but it is more concise and easy to read. The NOT IN variant works the reverse, with special care when subqueries generate NULL.
Key points
- IN checks the membership value on the list or subquery results.
- NOT IN is the opposite and should be wary of when it is.
- Logically equivalent to some abbreviated OR conditions.
- The value in the list should be the same as the column you're comparing.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.