Usage of MySQL conditional query statements

Source: Internet
Author: User

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. 1. = and! = (Equal and unequal)
  2.  
  3. SELECT f_name, l_name from employee_data where f_name = 'john ';
  4. + -------- + ------------ +
  5. | F_name | l_name |
  6. + -------- + ------------ +
  7. | John | Hagan |
  8. | John | MacFarland |
  9. + -------- + ------------ +
  10. 2 rows in set (0.00 sec)
  11.  

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)

 
 
  1. SELECT f_name, l_name from employee_data where age > 32;  
  2. +--------+------------+  
  3. | f_name | l_name     |  
  4. +--------+------------+  
  5. | John   | MacFarland |  
  6. | Hassan | Rajabi     |  
  7. | Paul   | Simon      |  
  8. | Roger  | Lewis      |  
  9. | Danny  | Gibson     |  
  10. | Mike   | Harper     |  
  11. | Peter  | Champion   |  
  12. +--------+------------+  
  13. 7 rows in set (0.00 sec)  
  14.  

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.