SQL OR Operator - The Coding Shala
Home >> Learn SQL >> SQL OR Operator
The following SQL query will return records if Age is 22 or Address in Pune -
Other Posts You May Like
Please leave a comment below if you like this post or found some error, it will help me to improve my content.
SQL OR Operator
The SQL 'OR' Operator is used to filter out the records based on the one or more columns. The WHERE clause can be combined with the OR operator. The SQL OR Operator displays records if any of the conditions that are separated by 'OR' are true.
SQL OR Operator syntax
The basic SQL OR operator syntax is as follows -
SELECT column1, column2, ... FROM table_name WHERE condition1 OR condition2 OR condition3 ...;
SQL OR Operator Examples
The following 'emp' will be used for the examples -
Id Name Age Address Salary 1 Akshay 22 Pune 40000 2 Mohit 21 Delhi 42000 3 Akash 21 Delhi 45000 4 Nikhil 24 Mumbai 50000 5 Smith 24 Pune 50000 6 Akshay 22 Pune 50000 7 Nikhil 24 Mumbai 43000
The following SQL query will return records if Age is 22 or Address in Pune -
SQL >> select * from emp where Age = 22 or Address = 'Pune'; Output >> Id Name Age Address Salary 1 Akshay 22 Pune 40000 5 Smith 24 Pune 50000 6 Akshay 22 Pune 50000
Other Posts You May Like
Prev<< SQL AND Operator NEXT >>SQL NOT Operator
Comments
Post a Comment