SQL
WHERE Clause

WHERE clause is used to filter records, and extract only the specific data that we want in any special case.

Operators of WHERE Clause

Below are operators that could be used with where clause in SQL.

OperatorDescription
=Equal
< >Not equal its is some time is used as !
>Greater than
<Less than
>=Greater than or equal
<=Less than or equal
BETWEENBetween a certain range
LIKESearch for a pattern
INTo specify multiple possible values for a column

Basic Syntax

SELECT statement can be used to select single column from a database.

Let’s assume we have a table named as customers and this table having multiple columns like customer_name, customer_address, customer_contact_no. We want to select all the data of customer the above select statement will be utilized.

                    


	SELECT column1, column2....columnN
	FROM table_name
	WHERE condition;

Examples

Select all the customers who belongs to Pakistan.

                    


	SELECT * FROM Customers
	WHERE Country='pakistan';

Select a customer by ID.

                    


	SELECT * FROM Customers
	WHERE CustomerID=20;