mysql> SELECT * FROM master_name;
+---------+---------------------+---------------------+-----------+----------+
| name_id | name_dateadded | name_datemodified | firstname | lastname |
+---------+---------------------+---------------------+-----------+----------+
| 1 | 2001-10-29 13:11:00 | 2001-10-29 13:11:00 | John | Smith |
| 2 | 2001-10-29 13:11:00 | 2001-10-29 13:11:00 | Jane | Smith |
| 3 | 2001-10-29 13:11:00 | 2001-10-29 13:11:00 | Jimbo | Jones |
| 4 | 2001-10-29 13:11:00 | 2001-10-29 13:11:00 | Andy | Smith |
| 7 | 2001-10-29 14:16:21 | 2001-10-29 14:16:21 | Chris | Jones |
| 7 | 2001-10-29 14:16:21 | 2001-10-29 14:16:21 | Chris | Jones |
答案 0 :(得分:0)
你可以尝试这样的事情。
SELECT MAX(name_id) FROM master_name
答案 1 :(得分:0)
SELECT t.*
FROM master_name
WHERE id = (SELECT MAX(name_id) FROM master_name)
答案 2 :(得分:0)
您甚至可以使用LIMIT
。
<强>查询强>
SELECT * FROM `master_name`
ORDER BY `name_id` DESC LIMIT 1;