It seems that the execution sequence of each keyword is unclear when you write SQL statements, and the SQL statements that you organize often lack good logic. (Sorry, if your SQL statements are often pieced together, do you have to reflect on it ?, Haha). It's really nice to be myself, but it's hard to get the machine, the server still needs to be in our mess
It seems that the execution sequence of each keyword is unclear when you write SQL statements, and the SQL statements that you organize often lack good logic. (sorry, if your SQL statements are often "pieced together", do you have to reflect on them ?, Haha). It's really nice to be myself, but it's hard to get the machine, the server still needs to be in our mess
It seems that the execution sequence of each keyword is unclear when you write SQL statements, and the SQL statements that you organize often lack good logic. (sorry, if your SQL statements are often "pieced together", do you have to reflect on them ?, Haha ). it is indeed a good job, but it is difficult for the server to find the keyword to be executed in our disorganized SQL statement. efficiency, because our sensory nerves are not sensitive to changes below seconds, we temporarily think that the order of SQL statements we write is irrelevant! ", Huh, huh. In fact, the server will have a detailed record of each SQL parsing time. You can take a look at the time difference between the SQL statements you are used to writing and the SQL statements written in standard order.
Therefore, we recommend that you write SQL statements in the standard sequence during your work. Professional and practical, but I think the most important thing is that you feel comfortable.
The standard SQL parsing sequence is:
(1). FROM clause to assemble data FROM different data sources
(2) The WHERE clause filters records based on specified conditions.
(3) group by clause, which divides data into multiple groups
(4). Use Aggregate functions for Calculation
(5). Use the HAVING clause to filter groups.
(6) Calculate all expressions
(7). Use order by to sort the result set
For example, in the student renewal table (temporarily recorded as tb_Grade), group the records whose "examinee name" is not empty by "examinee name" and filter the grouping results, select a score greater than 600 for the "Total score.
The standard order SQL statement is:
Select candidate name, max (total score) as max total score
From tb_Grade
Where examinee name is not null
Group by candidate name
Having max (total score)> 600
Order by max total score
In the preceding example, the SQL statement execution sequence is as follows:
(1) first, execute the FROM clause to assemble data FROM the tb_Grade table.
(2) execute the WHERE clause to filter data that is not NULL in the tb_Grade table.
(3) execute the group by clause to GROUP the tb_Grade table BY the "Student name" column.
(4) Calculate the max () Aggregation Function and calculate the maximum values in the total score by "total score ".
(5). Execute the HAVING clause to filter course scores greater than 600.
(7) Execute the order by clause to sort the final result BY "Max score.
Bytes --------------------------------------------------------------------------------------
Which of the following SQL statement types can I ask? the prototype of the SQL statement is;
1. select column list from table list name/View list name where condition.
2. select column list from table list name/View list name where condition group by (column list) having Condition
3. select column list from table list name/View list name where condition group by (column list) having condition order by column list
4. select column list from table 1 join table 2 on table 1. column 1 = table 2. column 1... join table n on table n. column 1 = TABLE (n-1 ). column 1 where table 1. condition and table 2. condition... table n. condition
What is the sequence of execution? For example, the first clause indicates that the where clause selects the result set that meets the conditions from the from table list, and then selects the column record set in the column list from the result set.
, Vm, Hong Kong server, US space