SQL IN OPERATOR
SQL IN OPERATOR:- The IN operator is used to specify multiple values in a WHERE clause.


The IN operator is a shorthand for multiple OR conditions.
SYNTAX:-
SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1 , value2 , ...);
EXAMPLE:-
Consider the following CUSTOMERS table:-
The following SQL query selects all customers that are located in "MP", "UP" or "Agra":-
SELECT Name ,Age,Salary
FROM Customers
WHERE Address IN ('MP', 'UP', 'Agra');
OUTPUT:-
The following SQL statement selects all customers that are NOT located in "MP", "UP" or "Agra":-
SELECT CustomerID , Name ,Age
FROM CUSTOMERS
WHERE Address NOT IN ('MP', 'UP', 'Agra');
OUTPUT:-
Comments
Post a Comment