Summary of the execution issues between mysql max and where

Summary of the execution issues between mysql max and where

Execution problem between mysql max and where

Execute sql:

CREATE TABLE `grades` (
 `id` int(20) NOT NULL AUTO_INCREMENT,
 `student_id` int(20) NOT NULL,
 `subject` varchar(20) COLLATE utf8_bin DEFAULT NULL,
 `grades` varchar(20) COLLATE utf8_bin DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
insert into `grades`(`id`,`student_id`,`subject`,`grades`) values ​​(1,1,'Chinese','80'),(2,1,'Mathematics','89'),(3,2,'Chinese','90');
CREATE TABLE `student` (
 `id` int(20) NOT NULL AUTO_INCREMENT,
 `name` varchar(20) COLLATE utf8_bin DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
insert into `student`(`id`,`name`) values ​​(1,'xiaoming'),(2,'xiaohong'),(3,'xiaobai');

Execution Result:

Execution result 1:

Execution result 2:

Execution result 3:

Execution result 4:

Execution result 5:

It can be seen from this that:

1.max is executed before the where condition,

2. Group by is executed before max

3. When where and group by appear at the same time, the where condition is executed first

Summarize

The above is a summary of the execution problems between mysql max and where that I introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

You may also be interested in:
  • MySQL left-join multi-table query where condition writing example
  • MySQL Where conditional statement introduction and operator summary
  • MySQL stored procedure parameter passing to implement where id in (1,2,3,...) example
  • Analyzing the difference between using on and where filtering in MySQL left (right) join
  • UCenter info: MySQL Query Error SQL:SELECT value FROM [Table]vars WHERE noteexists
  • MYSQL where 1=1 judgment function description
  • Tutorial on using the max() function in MySQL
  • Analysis of max_connections configuration parameters for MySQL performance optimization
  • How to configure the max_allowed_packet parameter in MySQL (to avoid failure in writing or updating large data)

<<:  Very practical Tomcat startup script implementation method

>>:  Detailed explanation of the working principle and solution of Js modularization

Recommend

Press Enter to automatically submit the form. Unexpected discovery

Copy code The code is as follows: <!DOCTYPE ht...

How to simply encapsulate axios in vue

Inject axios into Vue import axios from 'axio...

Undo log in MySQL

Concept introduction: We know that the redo log i...

Rendering Function & JSX Details

Table of contents 1. Basics 2. Nodes, trees, and ...

CSS implements five common 2D transformations

2D transformations in CSS allow us to perform som...

Four ways to create objects in JS

Table of contents 1. Create objects by literal va...

Detailed explanation of how to install PHP7 on Linux

How to install PHP7 on Linux? 1. Install dependen...

One line of CSS code to achieve the integration of avatar and national flag

It’s National Day, and everyone is eager to celeb...

CSS to achieve the sticky effect of two balls intersecting sample code

This is an effect created purely using CSS. To pu...

How to check if data exists before inserting in mysql

Business scenario: The visitor's visit status...

Detailed explanation of MySQL and Spring's autocommit

1 MySQL autocommit settings MySQL automatically c...

Vue.$set failure pitfall discovery and solution

I accidentally found that Vue.$set was invalid in...

Summary of the data storage structure of the nginx http module

Starting from this section, we will explain the i...

SQL implementation of LeetCode (197. Rising temperature)

[LeetCode] 197.Rising Temperature Given a Weather...