The OR operator allows you to create an SQL statement where records are returned when any one of the conditions are met. It can be used in any valid SQL statement - select, insert, update, or delete.

The syntax for the OR operator is:

SELECT [COLUMN NAME] FROM [TABLE NAME]
WHERE [CONDITION 1] OR [CONDITION 2]

In detailed syntax, the SQL syntax can be like this:

SELECT [COLUMN NAME] FROM [TABLE NAME]
WHERE [COLUMN 1] = [VALUE 1] OR [COLUMN 2] = [VALUE 2]

The OR condition requires that any of the conditions be must be met for the record to be included in the result set. In this case, [COLUMN 1] has to equal [VALUE 1] OR [COLUMN 2] has to equal [VALUE 2].


EXAMPLE :

We would like to return from the data to search person from IT Department or HR Department

Table GameScores

PlayerNameDepartmentScores
JasonIT3000
IreneIT1500
JaneMarketing1000
DavidMarketing2500
PaulHR2000
JamesHR2000

SQL statement :

SELECT PlayerName FROM GameScores
WHERE
Department = 'HR' OR Department = 'IT'

Result:

PlayerName
Jason
Irene
Paul
James