MySQL | Data Types | Conditions | Queries | Relationships | Scripts
Conditions are set in SQL statements to define rules when accessing data in a database. Conditions are coded with various operators.
These are logical operators...
AND (or &&)
both criteria must be true
OR (or ||)
either criteria must be true
NOT (or !)
not a value
LIKE like a specified pattern
NOT LIKE not like a specified pattern
BETWEEN in a range
WHERE to select data conditionally
These are wildcard operators...
% substitutes any collection of characters
( * for Access, UNIX...)
_ substitutes any individual character
( ? for Access, UNIX...)
These are arithmetic operators...
+ addition
- subtraction
* multiplication
/ division
These are comparison operators...
< less than
> greater than
<= less than or equal to
>= greater than or equal to
= equal to
<> not equal to
!= not equal to
These are built-in functions...
AVG returns the average of all values in a set
SUM returns the sum of all values in a set
COUNT counts the number of values in a set
MAX returns the maximum value in a set
MIN returns the minimum value in a set
*Examples of queries with conditions are on the Queries page.