Introduction to MySQL WHERE clause
The WHERE clause allows you to specify a search_condition for the rows returned by a query. The following shows the syntax of the WHERE clause:
SELECT
select_list
FROM
table_name
WHERE
search_condition;The search_condition is a combination of one or more expressions using the logical operator:
The followings are the syntax that can be use with WHERE
ANDORBETWEEN low AND highNOT BETWEEN low AND highLIKEINNOT INIS NULLIs Not NullCOMAPARSIONLIMIT
In MySQL, a predicate is a Boolean expression that evaluates to TRUE, FALSE, or UNKNOWN.
The SELECT statement will include any row that satisfies the search_condition in the result set. Besides the SELECT statement, you can use the WHERE clause in the UPDATE or DELETE statement to specify which rows to update or delete.
When executing a SELECT statement with a WHERE clause, MySQL evaluates the WHERE clause after the FROMclause and before the SELECT and ORDER BY clauses:
MySQL WHERE clause examples
We’ll use the employees table from the sample database for the demonstration:
