Introduction
The WHERE clause with OR lets you find rows that match at least one of several conditions. It helps you get more flexible search results.
SELECT column1, column2 FROM table_name WHERE condition1 OR condition2;
SELECT * FROM employees WHERE department = 'Sales' OR department = 'Marketing';
SELECT name FROM products WHERE price < 10 OR stock > 100;
SELECT * FROM orders WHERE status = 'Pending' OR status = 'Processing' OR status = 'Shipped';
CREATE TABLE fruits (id INT, name VARCHAR(20), color VARCHAR(20)); INSERT INTO fruits VALUES (1, 'Apple', 'Red'); INSERT INTO fruits VALUES (2, 'Banana', 'Yellow'); INSERT INTO fruits VALUES (3, 'Grape', 'Green'); INSERT INTO fruits VALUES (4, 'Cherry', 'Red'); SELECT * FROM fruits WHERE color = 'Red' OR color = 'Yellow';
WHERE clause with the OR operator do?WHERE clause with the OR operator to find employees in department 10 or 20?products with columns id, name, and category, what rows will this query return?SELECT * FROM products WHERE category = 'Books' OR category = 'Toys';
SELECT * FROM orders WHERE status = 'Pending' OR;
students with columns id, grade, and city. Write a query to select students who have grade 'A' or live in 'New York' or 'Los Angeles'. Which query is correct?Pass the test and this pattern moves unknown