How to use Multiple OR Operator In SQL

SELECT * FROM CoursesActive
WHERE courseId = 1001
OR courseId =1002
OR courseId = 1003

The Result Looks Like:

After Query run Our Table Looks

Explanation : In this query two OR operators are used with three condition courseId = 1001, courseId =1002, courseId = 1003 when any row with any of the three conditions is true there are only 3 rows.

SQL Server OR Operator

Logical operators are used for combining multiple boolean expressions which are a combination of results of multiple conditions which are formed by the comparators. Some of the logical operators are AND, OR, EXISTS, IN, LIKE, BETWEEN, etc, Logical operators are very frequently used and are very handy for testing multiple conditions. The logical operator OR is used for combining multiple boolean expressions and it returns true only when any one of the conditions is true. It is used primarily with WHERE, CASE, and HAVING clauses by specifying multiple boolean expressions that return any one of the following values True, or False.

Similar Reads

OR Operator Table

...

How to Use the OR Operator Step by Step

For Understanding the OR Operator in SQL Server in more depth manner, we need a table for executing operations or queries. So here we have a CoursesActive table. If you don’t know how to create table in SQL Server then you can refer to this for How to Create a Table in SQL Server...

Using Single OR operator

SELECT * FROM CoursesActiveWHERE courseId = 1001ORcourseName = 'Data Structures And Algorithms'...

Using Multiple OR Operator

SELECT * FROM CoursesActiveWHERE courseId = 1001OR courseId =1002OR courseId = 1003...

Using OR With Other Logical Operator

SELECT * FROM CoursesActiveWHERE courseId = 1001OR courseId =1002OR courseId = 1003OR courseId = 1004AND courseCost>1500...