Skip to the content.
< PREVIOUS   NEXT >

AND, OR and NOT OPERATOR

AND, OR and NOT are used with cobination of WHERE Clause.

SYNTAX



EXAMPLE

Suppose there is a Table name as “CustomerComplaint” having CustomerID, CustomerName, ProductName Issue, City, PostalCode and Country as columns.


Selects all fields from “CustomerComplaint” where country is “Germany” AND city is “Berlin”:

SELECT * FROM CustomerComplaint
WHERE Country='Germany' AND City=Berlin;


Selects all fields from “CustomerComplaint” where city is “Delhi” OR “Lucknow”:

SELECT * FROM CustomerComplaint
WHERE City='Delhi' OR City='Lucknow';


Selects all fields from “CustomerComplaint” where country is NOT “India”:

SELECT * FROM CustomerComplaint
WHERE NOT Country=India';


Selects all fields from “CustomerComplaint” where country is “India” AND city must be “Lucknow” OR “Delhi”.

SELECT * FROM CustomerComplaint 
WHERE Country='India' AND (City='Lucknow' OR City=Delhi');


Example: Selects all fields from “Customers” where country is NOT “Germany” and NOT “USA”:

SELECT * FROM CustomerComplaint
WHERE NOT Country=India AND NOT Country='Mexico';

< PREVIOUS || NEXT >

HOME