AND, OR and NOT Operators in SQL Server

AND, OR and NOT Operators in SQL Server

The WHERE clause can be combined with AND, OR and NOT operators

Syntax AND

SELECT column1, column2,column3, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3 AND condition4 ......

Syntax OR

SELECT column1, column2,column3, ......
FROM table_name
WHERE condition1 OR condition2 OR condition3 OR condition4 ...

Syntax NOT

SELECT column1, column2,column3, .......
FROM table_name
WHERE NOT condition

Example

SELECT * FROM Customers
WHERE Country='India' AND City='Delhi'
SELECT * FROM Customers
WHERE Country='India' OR Country='Nepal'
SELECT * FROM Customers
WHERE NOT Country='India'

 

2020-03-27