HOW TO USE IN OPERATOR IN SQL?

276 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ย INย (โ€˜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

A Tribute to Dilip Kumar