Use this space to put some text. Update this text in HTML

468x60 banner ad

Advertise with Us

Powered by Blogger.

Monday 18 April 2016

SQL OR Operator


The OR Operator is used to display result on the basis of any one condition are TRUE (means either first or second condition is true). 

The OR Operator returns the Boolean expressions that are TRUE or FALSE.

Syntax:
The basic syntax of OR operator with WHERE clause is as follows:

SELECT column1, column2, columnN
FROM table_name
WHERE [condition1] OR [condition2]...OR [conditionN];

Examples:

Please Read the Previous Article for SQL-Table Structure


Example1

Fetch First_name, Last_name, Salary, Department and City fields from the Employee table where First_name is Philip OR City is Mumbai.

SELECT First_name,Last_name, Salary, Department, City
FROM Employee
WHERE First_name='Philip' OR City='Mumbai'



Example2

Fetch First_name,Last_name, Salary, Department and City fields from the Employee table where City is Delhi OR salary greater than 650000.

SELECT First_name,Last_name, Salary, Department, City
FROM Employee
WHERE City='Delhi' OR Salary > 650000.00




Example3

Fetch First_name, Last_name, Salary, Department and City fields from the Employee table where City not in Delhi OR salary less than 1000000.

SELECT First_name,Last_name, Salary, Department,City
FROM Employee
WHERE City !='Delhi' OR Salary < 1000000.00










Friday 15 April 2016

SQL AND Operator

The AND Operator is used to display result on the basis of both condition are TRUE (means first and second condition are true). 

The AND Operator return the Boolean expressions that is TRUE or FALSE.

When more than one logical operator is used in a statement, the AND operators are evaluated first. 

Syntax:


The basic syntax of AND operator with WHERE clause is as follows:
 

SELECT column1, column2, columnN

FROM table_name

WHERE [condition1] AND [condition2]...AND [conditionN];

Examples:

Please Read the Previous Article for SQL-Table Structure  


Example1

Fetch First_name, Last_name, Salary, Department and City fields from the Employee table where First_name is Philip AND salary is 750000.

SELECT First_name,Last_name, Salary, Department, City
FROM Employee
WHERE First_name='Philip' AND Salary=750000

Example2

Fetch First_name,Last_name, Salary, Department and City fields from the Employee table where City is Delhi AND salary greater than 650000.

SELECT First_name,Last_name, Salary, Department, City
FROM Employee
WHERE City='Delhi' AND Salary > 650000.00

Example3

Fetch First_name,Last_name, Salary, Department and City fields from the Employee table where City not in Delhi AND salary less than 1000000.

SELECT First_name,Last_name, Salary, Department,City
FROM Employee
WHERE City !='Delhi' AND Salary < 1000000.00