SQL OR Condition in Queries
The SQL OR operator fetches records when at least one of multiple conditions is true. It works in SELECT, UPDATE, and DELETE statements, making it essential for flexible filtering.
Complete Python Course with Advance topics:-
SQL Tutorial:-
Syntax
SELECT columns FROM table_name
WHERE condition_1 OR condition_2;
OR in SELECT
SELECT * FROM emp
WHERE Department = 'IT' OR Location = 'Kolkata';
Returns rows where EITHER condition is true ÔÇö IT-department employees OR anyone in Kolkata.
OR in UPDATE
UPDATE emp
SET Location = 'Chennai'
WHERE Department = 'Marketing' OR Last_Name = 'Thakur';
OR in DELETE
DELETE FROM emp
WHERE Last_Name = 'Kapoor' OR Location = 'Bangalore';
Combining OR with AND
You can mix AND with OR ÔÇö use parentheses to control precedence (AND binds tighter than OR):
SELECT * FROM emp
WHERE Department = 'IT'
AND (Location = 'Kolkata' OR Location = 'Mumbai');
Tip: OR vs IN
When checking a single column against multiple values, IN is cleaner than chained ORs:
-- Chained OR
WHERE Location = 'Delhi' OR Location = 'Mumbai' OR Location = 'Pune'
-- Cleaner with IN
WHERE Location IN ('Delhi', 'Mumbai', 'Pune')
Download New Real Time Projects:- Click here
Complete Advance AI topics:-
Conclusion
The OR operator returns rows when at least one condition matches ÔÇö flexible and essential for everyday SQL filtering. Use parentheses to mix AND and OR safely, and prefer IN for many values on the same column. For more SQL tips, stay tuned to .
sql where multiple conditions
multiple if condition in sql
sql case when multiple conditions
sql if statement
sql or vs in
sql and or precedence
sql or condition example
sql or condition w3schools