SQL - IN & NOT IN CLAUSE

SQL IN operator is used to allow multiple value in a WHERE clause condition. It is similar to having MULTIPLE OR conditions

SQL IN CLAUSE

SYNTAX

50.png

EXAMPLE

Let’s fetch all the data from Persons table in our Demo Database where city is Bangalore or Pune:

SELECT * FROM PERSONS;

51.png
 

Figure 17.1. IN CITY (PUNE, MUMBAI)

 

SQL NOT IN operator is used to exclude multiple value in a WHERE clause condition. It is similar to a NOT condition.

SQL NOT IN

SYNTAX

52.png

EXAMPLE

Let’s fetch all the data from Persons table in our Demo Database where city is not Bangalore or Pune:

 

SELECT * FROM PERSONS;

53.png

PRACTICE YOURSELF 

54.png
 

Want More SQL Deep Dives