Query statement: 1. "select * from table name;" can query all the data in the table; 2. "select field name from table name;" can query the data of the specified field in the table; 3. "Select distinct field name from table name" can perform deduplication query on the data in the table.

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.
1. Ordinary query
(1) Command: (2) Command: 2 , Deduplication query (distinct) Command: 3. Sorting query (order by) Ascending order: asc Descending order: desc Descending order command: If desc is not added, the default is ascending order 4. Group by (group by) Command: Suppose there is another student score table (result). Request to query a student's total score. We divided them into different groups based on their student numbers. Command: 1. Equal value query Now there are two Table: query the failing grades of students younger than 20 years old. Statement: It can be seen that the equivalent query efficiency is too low 2. Connection query 1. Outer connection query (1) Left outer connection query Query the failing grades of students younger than 20 years old The filtered results of the left table must all exist. If there is filtered data in the left table and there is no match in the right table, NULL will appear in the right table; (2) Right outer join query The filtered results of the left table must all exist (3) Full outer join query 2. Inner join query mysql video tutorial】 The above is the detailed content of What is the query statement of mysql database. For more information, please follow other related articles on the PHP Chinese website!select * from / /通PI
select ;
select distinct
select < ;Field name to be queried> from order by
select group by
mysql>select id, Sum(score) from result group by id;
Multiple table query


select stu.id,score from stu,result where stu.id = result.id and age
The statement is:select a.id,score from (select id,age from stu where age < 20) a (过滤左表信息) left join (select id, score from result where score < 60) b (过滤右表信息) on a.id = b.id;
The left outer join is
select a.id,score from (select id,age from stu where age < 20) a (过滤左表信息) right join (select id, score from result where score < 60) b (过滤右表信息) on a.id = b.id;
Left outer join is




select a.id,score from (select id,age from stu where age < 20) a (过滤左表信息) inner join (select id, score from result where score < 60) b (过滤右表信息) on a.id = b.id;
[Related recommendations:
Related articles
See more