SQL Operators
 

SQL operators used in WHERE clause :

= Equal
SELECT * FROM Customers WHERE Country="India";
Country = "India"


<> Not equal. 
Country <> "Bangaladesh"
SELECT * FROM Customers WHERE Country <> "Bangladesh";

> Greater than
Salary > 40000

SELECT * FROM Employees WHERE Salary >40000;

< Less than
Age  < 18
SELECT * FROM Employees WHERE Age< 18;

>= Greater than or equal
Age  >= 18
SELECT * FROM Customers WHERE  Age>= 20;

<= Less than or equal
Age  <= 18
SELECT * FROM Customers WHERE  Age <= 20;

BETWEEN Between a range of values
SELECT * FROM Products WHERE Price BETWEEN 100 AND 200;
this will return all products price between 100 and 200

LIKE Search for a pattern in a field
SELECT * FROM Customers WHERE Country LIKE 'Sri%';
All records with "Sri" in front will return
IN specify multiple possible values for a column
SELECT * FROM Customers WHERE City IN ('London','Paris');
All records with "Sri" in front will return

AND

SELECT * FROM Customers WHERE  City='London' AND Country='UK';
All records with city London and country UK will return.

 

OR
SELECT * FROM Customers WHERE City='London' OR City='New York';
All records with city London or New York will return. 
(c) Shilpa Sayura Foundation 2006-2017