HOW TO USE IN OPERATOR IN SQL?

339 viewsSQLSQL
0

HOW TO USE IN OPERATOR IN SQL?

Saraswat World Changed status to publish June 8, 2023
0
IN in SQL
IN in SQL

IN operator is used to reduce use of multiple OR conditions by specifying multiple values in WHERE clause.

Syntax of IN operator in SQL –

SELECT(ColumnName(s))

FROM <TableName>

WHERE<ColumnName>

IN (value1, value2…valueN) ;

Example of IN operator in SQL-

SELECT *

FROM Customers

WHERE City

IN (‘Berlin’,’London’,’Madrid’);

–It will select all the customers from any of the cities Berlin, London and Mandrid.

NOT IN

Syntax of NOT IN operator in SQL –

SELECT(ColumnName(s))

FROM <TableName>

WHERE<ColumnName>

NOT IN (value1, ..…valueN) ;

Example of NOT IN operator in SQL-

SELECT *

FROM Customers

WHERE City

NOT I(‘Berlin’,’London’,’Madrid’);

–It will select all the customers that are not from any of the cities Berlin, London and Mandrid.

Note-

Northwind sample database is used for example.

Saraswat World Changed status to publish June 8, 2023
Write your answer.

Posted

in

Tags:

Comments

Leave a Reply

Ganesh Ji Arti A Tribute to Dilip Kumar