Home > Database > Mysql Tutorial > body text

Summary of execution issues between mysql max and where

php中世界最好的语言
Release: 2018-03-05 15:13:55
Original
2173 people have browsed it

In order to help everyone learn mysql better, this article mainly introduces a summary of the execution problems between mysql max and where. Friends in need can refer to it. I hope it will be helpful to everyone.

Execution issues 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,'语文','80'),(2,1,'数学','89'),(3,2,'语文','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');
Copy after login

Execution result:

Execution result 1:

##Execution result 2:

Execution result 3:

Execution result 4:

Execution result 5:

It can be seen that:

1.max is executed before the where condition,

2. group by is executed before max again

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

Summary

The above is a summary of the implementation issues between mysql max and where introduced by the editor. I hope it will be helpful to everyone.

Related recommendations:

MySQL Where condition

MYSQL WHERE statement optimization

appears Mysql max-connections problem solving

The above is the detailed content of Summary of execution issues between mysql max and where. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!