Preamble
PostgreSQL IN condition is used to reduce the need to use multiple OR conditions in SELECT, INSERT, UPDATE, or DELETE.
The syntax for IN condition in PostgreSQL
expression IN (value1_id, value2_id,... value_n_id);
OR:
IN (subquery_id);
Parameters and arguments of the condition
- expression – Value to be checked.
- value1_id, value2_id, or value_n_id – Values for checking expression for compliance.
- subquery_id – This is the SELECT operator, whose set of results will be checked for compliance. If any of these values correspond to an expression, the IN condition will have the value true.
Note:
- PostgreSQL condition IN will return records with value1, value2… or value_n.
- The PostgreSQL condition IN is also called the PostgreSQL IN operator.
Example IN condition with characters
Let’s consider an example of PostgreSQL IN conditions using character values.
Below is a PostgreSQL statement SELECT which uses the IN condition to compare character values:
SELECT *
FROM suppls
WHERE suppl_name IN ('Apple', 'Samsung', 'Asus');
In this PostgreSQL example, the IN condition will return all rows from the supplier’s table where supplier_name equals “Apple”, “Samsung” or “Asus”. Since SELECT uses *, all fields from the supplier table will be displayed in the resulting set.
The above IN example is equivalent to the following SELECT operator:
SELECT *
FROM suppls
WHERE suppl_name = 'Apple'
OR suppl_name = 'Samsung'
OR suppl_name = 'Asus';
As you can see, using PostgreSQL condition IN makes the operator easier to read and more efficient.
Example of a condition with numbers
Next, Let’s look at an example of PostgreSQL IN conditions using numeric values.
For example:
SELECT *
FROM empls
WHERE empl_id IN (300, 301, 500, 501);
This example of the PostgreSQL IN condition will return all records from the employee’s table for which employee_id is 300, 301, 500, or 501.
The above IN example is equivalent to the following SELECT statement:
SELECT *
FROM empls
WHERE empl_id = 300
OR empl_id = 301
OR empl_id = 500
OR empl_id = 501;
Example of a condition to using NOT operator
Finally, let us consider an example of the IN condition using the NOT operator.
For example:
SELECT *
FROM suppls
WHERE suppl_name NOT IN ('Apple', 'Samsung', 'Asus');
This example of PostgreSQL condition IN would return all rows from the supplier’s table where supplier_name is not “Apple”, “Samsung” or “Asus”. Sometimes it is more efficient to list the values that you don’t want, as opposed to the values that you want.
PostgreSQL Tutorial for Beginners – PostgreSQL IN Condition
About Enteros
IT organizations routinely spend days and weeks troubleshooting production database performance issues across multitudes of critical business systems. Fast and reliable resolution of database performance problems by Enteros enables businesses to generate and save millions of direct revenue, minimize waste of employees’ productivity, reduce the number of licenses, servers, and cloud resources and maximize the productivity of the application, database, and IT operations teams.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
What Drives Growth in Technology Platforms: Enteros AI SQL, Database Management, and Performance Metrics
- 11 March 2026
- Database Performance Management
Introduction Technology platforms have become the backbone of the modern digital economy. From SaaS products and cloud-native applications to AI-powered analytics and global digital marketplaces, technology enterprises rely on robust infrastructure to deliver reliable, scalable services to millions of users. At the center of these digital ecosystems lies one of the most critical components of … Continue reading “What Drives Growth in Technology Platforms: Enteros AI SQL, Database Management, and Performance Metrics”
How to Modernize Fashion Data Platforms with Enteros Database Management and Generative AI
Introduction The global fashion industry has transformed dramatically in the digital era. Once driven primarily by seasonal collections and physical retail, fashion brands today rely heavily on digital platforms, e-commerce marketplaces, data analytics, and AI-powered customer experiences. From trend forecasting and inventory management to real-time customer engagement, modern fashion businesses are powered by complex data … Continue reading “How to Modernize Fashion Data Platforms with Enteros Database Management and Generative AI”
How Banking Platforms Achieve Accurate Cost Estimation with Enteros GenAI and Cloud Cost Attribution
- 10 March 2026
- Database Performance Management
Introduction The banking industry is undergoing one of the most significant technological transformations in its history. Digital banking platforms, mobile payment systems, AI-powered fraud detection, and real-time financial analytics are now fundamental components of modern banking operations. These innovations rely on powerful cloud infrastructure and highly optimized databases to process millions of financial transactions every … Continue reading “How Banking Platforms Achieve Accurate Cost Estimation with Enteros GenAI and Cloud Cost Attribution”
From Performance Monitoring to Growth Intelligence: Enteros AIOps for Technology Enterprises
Introduction Technology enterprises are operating in an era where digital platforms determine market success. Software products, cloud platforms, SaaS applications, data analytics tools, and AI-powered systems are the backbone of modern businesses. Behind these digital services lies an intricate ecosystem of databases, cloud infrastructure, and applications that must operate at peak performance. For technology companies, … Continue reading “From Performance Monitoring to Growth Intelligence: Enteros AIOps for Technology Enterprises”