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










No comments :

Post a Comment

Ask a Question?