I. Summary
First Review: Connection query (several tables linked together to form a large table in the query---easy to forget) sub-query joint query see the basic article
Build the table order: first build the main table and then build the content from the table to fill in the main table before filling out from the table
Parentheses:
1. Parentheses can represent the part of the independent operation
2. With parentheses is the method () For example , count (); where to find the specified line:
#--- check the records of all students in class 95033 and class 95031. Selectfrom where student.sno=score.sno and Course.cnoclass= ' 95033 ' class='95031')
Key Words :
commas are important; almost all statements can be nested using
Select: From , where , Group by have; Order by
distanct; or; in; and; Not
1.not:not in (see Front Mysqle Foundation) and not-like
#- Query student table in the "King" of the classmate record. Select * from Student where Sname don't like' King%'
2. When the group by and where, COUNT (*) is used with the note [notation with parentheses}
Define first: a function that performs a calculation on a column in a set of rows and returns a single value. 1.whereand having a simple, where condition is a field, and a having condition can be a field or a aggregation function; it is important that where is the filter source data, having much to do with group by, and the condition is often the aggregation function; when there is a group By, it has to be behind the group by condition, and where is in front of group by. Aggregation function: Sum,count,avg ... And so on;2. Count and Sumcount are ' cumulative '; sum is ' accumulate ', or the table A_info above, and the number of people with scores greater than 60 in each grade and their average score:3the execution order of the. SQL statement: (1) fromSelect a data source;2)wherefilter the data source;3Group by groups the filtered data sources;4) is calculated using the aggregate function;5) Having the data to filter the groupings;6) evaluates an expression;7) Order by sort;
Group where COUNT (*) is also used to explain
#---- Check the class number of at least 2 men. Selectclass from Student where ssex=' man ' class having count (*) >=2
3.DISTANCT: See the basic part of the method of use not to repeat
4. get time and date see the next blog below for a brief
Gets an integer that can be compared for size:
Gets the year (Time column name)----column name is not quoted
Gets the current time date (now ())
Get Day date (the column where the time is)
#---- Query the name and age of each student in the student table. the Select from student#--- queries the maximum and minimum sbirthday date values in the Student table. Select from studentunionSelect from student#--- Query all records in the student table in order of class number and age from large to small. Selectfromclass
Mysql Practice Summary