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:
- + -------- + ---------- + --------- + ------------ + --------- +
- | 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> '2017-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 <'2017-12-01 'and emp_sal> 1979;
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.