PostgreSQL IN Operator

PostgreSQL IN Operator Determines whether a specified value matches any value in a subquery or a list. PostgreSQL IN picks one by value from list of values. Instead of putting multiple ‘OR’ operator, use IN operator.

PostgreSQL IN Syntax:

SELECT column1, column2, ..... columnN FROM table_name WHERE test_expression [ NOT ] IN ( subquery | expression [ ,...n ] );

PostgreSQL IN Examples:

Belwo table is used for PostgreSQL IN operator exmaple.

1. Display employees whose job is either ‘MANAGER’ or ‘CLERK’.

select * from emp where job in('MANAGER', 'CLERK');

PostgreSQL IN Operator

2. Display employees who is belongs to department no 10 or 30.