MySQL condition query statements are one of our most commonly used statements. The following describes MySQL condition query statements in detail. If you are interested in MySQL condition query statements, take a look.
How can I query data with conditions?
The Comparison Operators (Comparison Operators) is required for the MySQL conditional query statement-WHERE, which roughly includes the following types:
- 1. = and! = (Equal and unequal)
-
- SELECT f_name, l_name from employee_data where f_name = 'john ';
- + -------- + ------------ +
- | F_name | l_name |
- + -------- + ------------ +
- | John | Hagan |
- | John | MacFarland |
- + -------- + ------------ +
- 2 rows in set (0.00 sec)
-
In the above example, we use the = comparison operator to query the f_name and l_name In the table, but not all, but only the 'john' name.
Note:
Do not write =.
Mysql is case-insensitive, that is, you can write it as f_name = "JOHn"
If the query condition is for age, no quotation marks are required because age is a real number, for example, age = 33.
Opposite to = ,! = Indicates the case of inequality
2.> and <(greater than or less)
- SELECT f_name, l_name from employee_data where age > 32;
- +--------+------------+
- | f_name | l_name |
- +--------+------------+
- | John | MacFarland |
- | Hassan | Rajabi |
- | Paul | Simon |
- | Roger | Lewis |
- | Danny | Gibson |
- | Mike | Harper |
- | Peter | Champion |
- +--------+------------+
- 7 rows in set (0.00 sec)
-
In the above example, we use the> comparison operator to query the f_name and l_name In the table, but only the case where the age is more than 32 years old. Less than or greater than the opposite.
3. >=and <=greater than or equal to and less than or equal
Implementation of MySQL non-repeated Query
Introduction to transcoding in mysql command line cmd Environment
Five common MySQL command lines
Mysql command line parameters
How to import SQL data through Mysql command lines