SQL OR Keyword

The OR operator in SQL combines multiple conditions within a WHERE clause. It selects rows where at least one of the conditions is true.



OR: Definition and Usage

The OR operator acts as a logical "or"—it means "this condition *or* that condition (or both) must be true". If one or more of the conditions connected by OR are true, the entire expression evaluates to true, and the corresponding row is included in the query results. Only if *all* conditions linked by `OR` are false will the row be excluded.

Syntax

Syntax

SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;
      

Example

Selecting Customers from Multiple Cities

This query retrieves all customers from either Berlin or München. (This assumes a 'Customers' table exists with a 'City' column.)

Syntax

SELECT * FROM Customers
WHERE City = 'Berlin' OR City = 'München';
      
Output

(All rows from the Customers table where City is 'Berlin' or 'München' will be returned.)
      

**Note:** The example output will vary depending on the data in your `Customers` table. If no customers are from Berlin or München, the output will be an empty dataset. Remember that you can combine multiple conditions using `OR` in your `WHERE` clause to create more flexible queries.