SQL OR

SQL OR clause is used to select data when any of the two conditions are met.

The syntax of SQL OR clause is

SELECT columns
FROM table
WHERE condition1 OR condition2;

 

SQL OR is executed when any of the both conditions are met.

Example:

Let us take a Student Table.

StudentIDStudent_NameAddressCity
1NithinBank StreetHyderabad
2BharathWhite FieldBangalore
3GouthamAvenue colonyChennai
4BhargavJames streetChennai
5VarunPark AvenueChennai


Now we select the data where the Student City is Hyderabad or Address is Park Avenue.

The Query is written as:

SELECTStudent_NameFROM Student
WHERE
City=’Hyderabad’ OR Address=’Park Avenue’;

 

The output is displayed as

Student_Name
Nithin
Bharath
Goutham
Bhargav
Varun

 

OR Clause can be used with INSERT, UPDATE & DELETE statements.