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

How to view the IP address of Linux in VMware virtual machine

1. First, double-click the vmware icon on the com...

Vue implements carousel animation

This article example shares the specific code of ...

HTML table tag tutorial (8): background image attribute BACKGROUND

Set a background image for the table. You can use...

How to set MySQL foreign keys for beginners

Table of contents The role of foreign keys mysql ...

Use jQuery to fix the invalid page anchor point problem under iframe

The application scenario is: the iframe page has n...

Detailed tutorial on installing CentOS, JDK and Hadoop on VirtualBox

Table of contents 1. Prerequisites 1.1 Supported ...

Detailed explanation of CSS counter related attributes learning

The CSS counter attribute is supported by almost ...

Detailed tutorial on using cmake to compile and install mysql under linux

1. Install cmake 1. Unzip the cmake compressed pa...

Execute the shell or program inside the Docker container on the host

In order to avoid repeatedly entering the Docker ...

A brief analysis of React's understanding of state

How to define complex components (class component...

Elementui exports data to xlsx and excel tables

Recently, I learned about the Vue project and cam...

Steps to completely uninstall the docker image

1. docker ps -a view the running image process [r...

How to backup MySQL regularly and upload it to Qiniu

In most application scenarios, we need to back up...