The logical operators and, or, and not connect search conditions in where clauses.
{where | having} [not] column_name join_operator column_name
where join_operator is a comparison operator and column_name is the column used in the comparison. Qualify the name of the column if there is any ambiguity.
and joins two or more conditions and returns results only when all of the conditions are true. For example, the following query finds only the rows in which the author’s last name is Ringer and the author’s first name is Anne. It does not find the row for Albert Ringer.
select * from authors where au_lname = "Ringer" and au_fname = "Anne"
or also connects two or more conditions, but it returns results when any of the conditions is true. The following query searches for rows containing Anne or Ann in the au_fname column.
select * from authors where au_fname = "Anne" or au_fname = "Ann"
You can specify as many as 252 and and or conditions.
not negates the expression that follows it. The following query selects all the authors who do not live in California:
select * from authors where not state = "CA"
When more than one logical operator is used in a statement, and operators are normally evaluated before or operators. You use parentheses to change the order of execution. For example:
select * from authors where (city = "Oakland" or city = "Berkeley") and state = "CA"