Explore BrainMass

Using OR, AND, ANY, and ALL with SQL queries

The OR and AND operators are used in compound conditions. Is there any relationship between these operators and the ALL and ANY operators? Outside references are required.

© BrainMass Inc. brainmass.com August 17, 2018, 5:05 am ad1c9bdddf

Solution Preview

The MySql operators OR and AND can be used in conditions in a query. For example:

SELECT * FROM mytable WHERE id > 100 AND age < 65;

This statement selects all the items from the table where the id is
greater than 100 AND the age is less than 65. Both conditions must be
met. Likewise, the following query uses the OR operator:

SELECT * FROM mytable ...

Solution Summary

This solution shows how to use OR, AND, ANY, and ALL in SQL queries. It also explains how they work.