Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Tuesday, April 16, 2013

7 : SQL "WHERE" Clause

The WHERE clause is used to filter records.
That is , The WHERE clause is used to extract only those records that fulfill a specified criterion.


The created Table is : 


Create a Database named "Studysql" and a table named "tbl_biodata"
Right click on the database Studysql and select new query.Then we can write queries as per the requirements.
( Click here to know how created this table )

ID
NAME
AGE
CITY
PHONE
1
Priyada
25
Cochin
1000000001
2
Mohan
30
Cochin
2000000002
3
Jaimon Jacob
40
Vytila
3000000003
4
Sumith
24
Kottayam
4000000004
5
Shaiju
36
Thrissur
5000000005


Now we want to select only the persons living in the city "Thrissur" from the table above.


To do so, write the command like this in SQL.


SELECT * FROM tbl_biodata WHERE city='Thrissur'



The result-set will look like this:





SQL SELECT Syntax of the same is : 

SELECT column_name(s)
FROM table_name
WHERE column_name operator value
============================================================================================

Note : Operators Allowed in the WHERE Clause



With the WHERE clause, the following operators can be used:
OperatorDescription
=Equal
<>Not equal
>Greater than
<Less than
>=Greater than or equal
<=Less than or equal
BETWEENBetween an inclusive range
LIKESearch for a pattern
INTo specify multiple possible values for a column
Note: In some versions of SQL the <> operator may be written as !=

=================================================================================

No comments: