MySQL statistics function
Count (): Statistic quantity;
Max (): Statistical maximum;
Min (): Minimum statistical value;
AVG (): Statistical averages;
SUM (): statistics and;
Select Count (* from student;
MySQL sort group by;
The default is ascending sort;
Select * fromStudentGroup bySidASC;--Sort AscendingSelect * fromStudentGroup bySidDESC;--Sort DescendingSelect * fromStudentGroup bySid,sname;---Multi-field sorting
Having the same use method and where, the function is more powerful than where;
Limit limit Query
Limit queries a specified number of data in a data table
Limit can only limit the query
Mainly used to achieve paging effect;
Select * from 1 ; -- Query 1 Data Select * from 1,2; -- starting from subscript 1 to query two data;
MySQL connection query
Cross joins: Crosses join; loops out each record from a table, each record is connected to another table;
Connection mode: Left table cross join right table;
Inner joins: Left table inner join right table on condition;
Alias: As (can save As)
External links: outer join;
Outer LEFT join;
outer right join;
Select * fromStudent Cross JoinStudent2;Select * fromStudentInner JoinStudent2 onStudent.sid=Student2.sid;Select * fromStudent asAInner JoinStudent2 b onA.sid=B.sid;Select * fromStudent asA Left outer JoinStudent2 b onA.sid=B.sid;Select * fromStudent asA Right outer JoinStudent2 b onA.sid=B.sid;
Multi-Table Query Union (ALL;DISTINCT)
All: Do not go to the weight, keep all the data;
Distinct: Remove weight (default);
MySQL Learning Path (v) MySQL advanced query