Breaking News

WHERE clause

Where clause is used to specify condition while retriving data from table. Where clause is used mostly withSelect, Update and Delete query. If condititon specified by where clause is true then only the result from table is returned.


Syntax for WHERE clause

SELECT column-name1, 
 column-name2, 
 column-name3, 
 column-nameN 
from table-name WHERE [condition];

Example using WHERE clause

Consider a Student table,

s_id s_Name age address
101 Adam 15 Noida
102 Alex 18 Delhi
103 Abhi 17 Rohtak
104 Ankit 22 Panipat

Now we will use a SELECT statement to display data of the table, based on a condition, which we will add to the SELECT query using WHERE clause.

SELECT s_id, 
 s_name, 
 age, 
 address 
from Student WHERE s_id=101; 
s_id s_Name age address
101 Adam 15 Noida