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');
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 again3. When where and group by appear at the same time, the where condition is executed firstSummary
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 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!