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.
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 )
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.
The result-set will look like this:
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
============================================================================================
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:
Operator | Description |
---|---|
= | Equal |
<> | Not equal |
> | Greater than |
< | Less than |
>= | Greater than or equal |
<= | Less than or equal |
BETWEEN | Between an inclusive range |
LIKE | Search for a pattern |
IN | To specify multiple possible values for a column |
Note: In some versions of SQL the <> operator may be written as !=
=================================================================================
No comments:
Post a Comment