• IN clause can be use for searching operation.
  • It searches for the records with specific criteria.
  • It displays those records that are matches with the values specified into the IN clause.
  • It is an alternative for ‘=’ and ‘OR’ operator.
  • The same result can be derived by using IN clause.
  • We can also specify IN clause for negative searching by adding NOT keyword.
  • When using NOT IN clause it will display those records that do not match with values specified in to the IN clause.

Syntax:

SELECT * FROM <table name> WHERE <expression> IN <val1, val2,…,val N>;

Example:

SELECT * FROM student WHERE city IN (‘Rajkot’, ’Bhavanagar’);
SELECT * FROM student WHERE city NOT IN (‘Ahemdabad’);
  • The 1st command will display student records that are from Rajkot and Bhavnagar.
  • The 2nd command will display student records except the city Ahemdabad.