Continue to update the beginner MySQL today, and the following are the commands for the required lookup table. Usage Table: Student
1, Query table All field data: SELECT * from student;
2. Query data for a field: select name from student;
3. Querying data for multiple fields: select Name, Kemu,score from student;
4, based on criteria query (WHERE): SELECT * FROM student where score>80;
5. Query based on multiple criteria (where ... and.): SELECT * from student where kemu= ' PE ' and score>80;
6, according to the name of the first letter of the student query: SELECT * FROM student where name like ' j% ';
7, sorted by student score (ascending ASC, descending desc) query (ORDER BY): SELECT * FROM student order by score ASC;
8, according to the keyword (in) query: SELECT * FROM student where ID in (A/n);
9, the interval of the query score (between and): SELECT * from student where score between and 90;
10, query score non-duplicated data (DISTINCT): SELECT distinct name, score from student;
11, packet query (group BY): SELECT * FROM student group by name;
12, limit the number of query results (LIMIT): SELECT * FROM Student ORDER by ASC limit 5;
13, using the common function count () query, the benefit: If the query field is NULL, it will not be queried:
Select COUNT (*) from student;
14, use the common function sum () To sum: select SUM (score) from student;
15, using the usual function avg () Averaging: Select AVG (score) from student;
16, use the usual function min () to find the minimum value, max () to find the maximum value:
Select Max (Score), Min (score) from student;
Today, temporarily updated to here!
Beginner MySQL Summary (2)