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.