How can I select the row with the highest ID in My

2020-02-18 03:34发布

How can I select the row with the highest ID in MySQL? This is my current code:

SELECT * FROM permlog WHERE max(id)

Errors come up, can someone help me?

标签: mysql
8条回答
Emotional °昔
2楼-- · 2020-02-18 04:00
SELECT *
FROM permlog
WHERE id = ( SELECT MAX(id) FROM permlog ) ;

This would return all rows with highest id, in case id column is not constrained to be unique.

查看更多
祖国的老花朵
3楼-- · 2020-02-18 04:03
SELECT * FROM permlog ORDER BY id DESC LIMIT 0, 1
查看更多
登录 后发表回答