How to get a row that has the maximum value in a column?
This below 开发者_开发技巧works for me but I don't know if there is another cleaner way..
SELECT * FROM `moto` where (matricula = (SELECT max(matricula) FROM `moto`))
Nope, this is the way to go. Mind you, this will get you all the rows with that max, if there are multiple
(This query is also featured in one of my MySQL book (o'reilly). It's sort of a classic example)
You can also do SELECT * FROM moto ORDER BY matricula DESC LIMIT 1
精彩评论