SQL Oracle Java JSP JDBC PHP MORE

Oracle NOT IN Operator with Example

In Oracle the NOT IN operator used to compare a column with one or more than one value.

It always used with where clause.

Oracle NOT IN Operator Syntax

To add a column in a table, the syntax is

SELECT column_name(s)
FROM table_name
WHERE column_name NOT IN (value1, value2, ...);
Example

Suppose we have to fetch all record from the user_table where city name is equal to Pune, Mumbai.In this case we have to use IN operator.

Sl No Name City Email ID
1 Virat Delhi [email protected]
2 Sachin Mumbai [email protected]
3 Dhoni Ranchi [email protected]
4 Raina Pune [email protected]
SELECT * FROM Customers WHERE City NOT IN ('Pune', 'Mumbai');

Output

Sl No Name City Email ID
1 Virat Delhi [email protected]
3 Dhoni Ranchi [email protected]