• Teach Your Self With
             w3htmlschool.com

MySQL WHERE clause

The MYSQL where clause is the mechanism for selecting the row you want for your result set.

Syntax


SELECT DISTINCT
columns
FROM
table_name
WHERE
where_conditions;
Example
SELECT code,name from Country where continent="asia"
Output
mysql> SELECT code,name from Country where continent="asia";
+------+----------------------+
| code | name |
+------+----------------------+
| AFG | Afghanistan |
| ARE | United Arab Emirates |
| ARM | Armenia |
| AZE | Azerbaijan |
| BHR | Bahrain |
| BGD | Bangladesh |
| BTN | Bhutan |
| BRN | Brunei |
| PHL | Philippines |
| GEO | Georgia |
| HKG | Hong Kong |
| IDN | Indonesia |
| IND | India |
expressions in WHERE clauses can use the following type of operation:

Arithmetic for calculation
Camparison for comparison of one expression with another expression.
Logical to combine different WHERE condition.

Parameter


Arithmatic Operation
OperationDefination
+Addition
-Subtraction
*Multiplication
/Division
divInterger Division
%Modulo


Comparison Operator

OperationDefination
<Less then
>=Less then or equal to
=Equal to
<=>Equal (work even for NULL values)
<> or !=Not equal to
>=Greater than or equal to
>Greater than or equal to
Between … and. .Indicate a range of values

Logical

OperationDefination
ANDLogical AND
ORLogical OR
XORLogical exclusive OR
NOTLogical negation