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

8 : SQL " AND & OR "Operators

The AND & OR operators are used to filter records based on more than one condition.


The AND operator displays a record if both the first condition and the second condition are true.
The OR operator displays a record if either the first condition or the second condition is true.

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



1 . AND Operator Example


Now we want to select only the persons with the name equal to "Priyada" AND the city equal to "Cochin":

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

select * from tbl_biodata where names='Priyada' and city='Cochin'



The result-set will look like this:


2 . OR Operator Example

Now we want to select only the persons with the first name equal to "Priyada" OR the first name equal to "Mohan":


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

SELECT * FROM tbl_biodata WHERE names='Priyada' OR names='Mohan'



The result-set will look like this:




NEXT CHAPTER

PREVIOUS CHAPTER


No comments: