How to select a maximum value row in mysql table

前端 未结 7 1593
感情败类
感情败类 2020-12-15 06:30

I have the following table

Table structure:

CREATE TABLE IF NOT EXISTS `people` ( 
`name` varchar(10) NOT NULL, 
`age` smallint(5) u         


        
7条回答
  •  南笙
    南笙 (楼主)
    2020-12-15 07:03

    Question 1 : If you really want to use the MAX() you could try this SELECT age, name FROM people WHERE age IN (SELECT MAX(age) FROM people);

    Question 2: I think it depends, for my suggestion in question 1, you do the query twice, but in the ORDER BY solution you provided, the database performed a sort like procedure.

提交回复
热议问题