Logical OR filters rows when at least one connected condition is true. In a WHERE clause, it is useful when a request allows alternatives: find titles with an Advance of 5,000 or a Royalty of 15 percent. section 5.2.2
Finding titles that meet either condition
SELECT TitleName, Advance, Royalty FROM title WHERE Advance = 5000 OR Royalty = 15; A row needs to match only one condition, so this returns more rows than requiring both conditions with AND. Adding another OR condition, such as Price = 9.95, can include still more rows. section 5.2.2
When OR is combined with AND, use parentheses to make the intended grouping explicit. SQL evaluates AND before OR, so Price = 9.95 AND (PublicationDate = '2016-02-06' OR Advance = 5000) keeps the price requirement in force for either alternative. section 5.2.3
Practical checks:
- Use OR when any one of several conditions should include a row. section 5.2.2
- Use parentheses whenever AND and OR appear together; they prevent unintended results and make the logic easier to read. section 5.2.3
- Match filtered values exactly, and avoid quoting numeric values because implicit conversion can affect query duration. section 5.4
SELECT
TitleName,
Price,
PublicationDate,
Advance
FROM title
WHERE Price = 9.95
AND (PublicationDate = '2016-02-06'
OR Advance = 5000);
This query demonstrates keeping Price fixed while allowing either a publication date or an advance to satisfy the grouped alternative. section 5.2.3





