Query records of MySQL advanced query methods

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff. This article mainly 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:

Welcome to the Linux community forum and interact with 2 million technical staff> 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:

Welcome to the Linux community forum and interact with 2 million technicians>

This article mainly describes the actual operation steps for querying records of MySQL advanced query methods, as well as detailed descriptions of the Code to be used in the actual operation process, the following is a detailed description of the main content of the article. I hope you will have a better understanding of it after browsing.

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:

+ -------- + ---------- + --------- + ------------ + --------- +

| Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |

+ -------- + ---------- + --------- + ------------ + --------- +

| 100005 | Xiaotian | 27 | 4000 | 1979-07-10 | male |

+ -------- + ---------- + --------- + ------------ + --------- +

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.

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:

+ -------- + ---------- + --------- + ------------ + --------- +

| Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |

+ -------- + ---------- + --------- + ------------ + --------- +

| 100001 | Hongfeng | 29 | 9000 | male |

| 100002 | Lili | 27 | 8000 | 1979-12-31 | fmale |

+ -------- + ---------- + --------- + ------------ + --------- +

2 rows in set (0.00 sec)

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

MySQL (best combination with PHP)> select * from emp where emp_bir> 1978-01-01;

The query result is as follows:

+ -------- + ---------- + --------- + ------------ + --------- +

| Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |

+ -------- + ---------- + --------- + ------------ + --------- +

| 100005 | Xiaotian | 27 | 4000 | 1979-07-10 | male |

| 100002 | Lili | 27 | 8000 | 1979-12-31 | fmale |

+ -------- + ---------- + --------- + ------------ + --------- +

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

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

The query result is as follows:

+ -------- + ---------- + --------- + ------------ + --------- +

| Emp_id | emp_name | emp_age | emp_sal | emp_bir | emp_sex |

+ -------- + ---------- + --------- + ------------ + --------- +

| 100001 | Hongfeng | 29 | 9000 | male |

+ -------- + ---------- + --------- + ------------ + --------- +

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.