SQL WHERE

The  Where  clause is use to get the exact value from a record.

You can also get values by giving condition. 

Note: The WHERE clause is not only used in SELECT statements, it is also used in UPDATE, DELETE, etc.!

 

Syntax:

SELECT * FROM table_name WHERE condition;

 

Example Database:

This is  customers  table

id name Location
1 Kailash Delhi
2 Amit Haryana
3 Siddarth Noida
3 Vikas Noida

 


 

WHERE Clause Example:

Example1: Select all the customers from noida location

Syntax:

SELECT * FROM customers WHERE location = 'Noida';

 

Result:

id name Location
3 Siddarth Noida
4 Vikas Noida

 

Example2: Select customer details using id.

Syntax:

SELECT * FROM customers WHERE id= 3;

 

Result:

id name Location
3 Siddarth Noida

 

Example3: Select name from customers table. Which is belongs to noida location

Syntax:

SELECT name FROM customers WHERE location = 'Noida';

 

Result:

name
Siddarth
Vikas