MySQL advanced query method-record query _ MySQL

Source: Internet
Author: User
This article describes how to query records of MySQL advanced query methods, the detailed description of the code used in the actual operation process is as follows:

Query all emp_name information in the emp table.

MySQL (the best combination with PHP)> select * from emp where emp_name = 'xiaotian ';

The query result is as follows:

 
 
  1. + -------- + ---------- + --------- + ------------ + --------- +
  2. | Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |
  3. + -------- + ---------- + --------- + ------------ + --------- +
  4. | 100005 | Xiaotian | 27 | 4000 | 1979-07-10 | male |
  5. + -------- + ---------- + --------- + ------------ + --------- +
  6. 1 row in set (0.00 sec)

Query all the information of emp_sal in the emp table with a salary of more than 5000.

 
 
  1. MySQL (best combination with PHP)> select * from emp where emp_sal> 5000;

The query results of the MySQL advanced query method record query are as follows:

 
 
  1. + -------- + ---------- + --------- + ------------ + --------- +
  2. | Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |
  3. + -------- + ---------- + --------- + ------------ + --------- +
  4. | 100001 | Hongfeng | 29 | 9000 | male |
  5. | 100002 | Lili | 27 | 8000 | 1979-12-31 | fmale |
  6. + -------- + ---------- + --------- + ------------ + --------- +
  7. 2 rows in set (0.00 sec)

Queries the emp table that was born after January 1, January 1, 1978

 
 
  1. MySQL (best combination with PHP)> select * from emp where emp_bir> '2017-01-01 ';

The query result is as follows:

 
 
  1. + -------- + ---------- + --------- + ------------ + --------- +
  2. | Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |
  3. + -------- + ---------- + --------- + ------------ + --------- +
  4. | 100005 | Xiaotian | 27 | 4000 | 1979-07-10 | male |
  5. | 100002 | Lili | 27 | 8000 | 1979-12-31 | fmale |
  6. + -------- + ---------- + --------- + ------------ + --------- +
  7. 2 rows in set (0.00 sec)

Query the emp table that was born before January 1, December 1, 1979 and has a salary of more than 5000

 
 
  1. MySQL (best combination with PHP)> select * from emp where emp_bir <'2017-12-01 'and emp_sal> 1979;

The query result is as follows:

 
 
  1. + -------- + ---------- + --------- + ------------ + --------- +
  2. | Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |
  3. + -------- + ---------- + --------- + ------------ + --------- +
  4. | 100001 | Hongfeng | 29 | 9000 | male |
  5. + -------- + ---------- + --------- + ------------ + --------- +
  6. 1 row in set (0.00 sec)

The above content is the description of the record query in the advanced query, hoping to help you in this aspect.

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.