🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to PostgreSQL Notes
Topic #27

PostgreSQL IN


IN

The IN operator allows you to specify a list of possible values in the WHERE clause.

The IN operator is a shorthand for multiple OR conditions.

Example

SELECT * FROM customers
WHERE country IN ('Germany', 'France', 'UK');

NOT IN

By using the NOT keyword in front of the IN operator, you return all records that are NOT any of the values in the list.

Example

SELECT * FROM customers
WHERE country NOT IN ('Germany', 'France', 'UK');

IN (SELECT)

You can also use a SELECT statement inside the parenthesis to return all records that are in the result of the SELECT statement.

Example

SELECT * FROM customers
WHERE customer_id IN (SELECT customer_id FROM orders);

NOT IN (SELECT)

The result in the example above returned 89 records, that means that there are 2 customers that haven't placed any orders.

Let us check if that is correct, by using the NOT IN operator.

Example

SELECT * FROM customers
WHERE customer_id NOT IN (SELECT customer_id FROM orders);

Want to go beyond the notes?

Join CodingNow 2.0's PostgreSQL course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

PostgreSQL IN – FAQs

Quick answers about learning PostgreSQL IN in PostgreSQL.

This free note from CodingNow 2.0 explains PostgreSQL IN in PostgreSQL — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every PostgreSQL topic on CodingNow 2.0, including PostgreSQL IN, is 100% free with no signup required.
With focused practice, most students grasp PostgreSQL IN in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now