如何选择表中ID最大的整行? [英] How do I select an entire row which has the largest ID in the table?
本文介绍了如何选择表中ID最大的整行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该怎么做?
SQL SELECT row FROM table WHERE id=max(id)
推荐答案
您可以使用子选择:
SELECT row
FROM table
WHERE id=(
SELECT max(id) FROM table
)
请注意,如果max(id)
的值不是唯一的,则返回多行.
Note that if the value of max(id)
is not unique, multiple rows are returned.
如果只想要这样的一行,请使用@MichaelMior的答案,
If you only want one such row, use @MichaelMior's answer,
SELECT row from table ORDER BY id DESC LIMIT 1
这篇关于如何选择表中ID最大的整行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文