MySQL where condition
MySQL where condition
WHERE Syntax
SELECT column1, column2, …
FROM table_name
WHERE condition;
Note: The WHERE clause is not only used in SELECT statement, it is also used in UPDATE, DELETE statement, etc.!
SELECT * FROM Customers WHERE Country=’Mexico’;
Operators in The WHERE Clause
The following operators can be used in the WHERE clause:
Operator | Description |
---|---|
= | Equal |
<> | Not equal. Note: In some versions of SQL this operator may be written as != |
> | Greater than |
< | Less than |
>= | Greater than or equal |
<= | Less than or equal |
BETWEEN | Between a certain range |
LIKE | Search for a pattern |
IN | To specify multiple possible values for a column |
SELECT * FROM Customers WHERE CustomerID=1;