📅  最后修改于: 2020-11-19 00:40:10             🧑  作者: Mango
MySQL的last函数用于返回所选列的最后一个值。
句法:
SELECT column_name
FROM table_name
ORDER BY column_name DESC
LIMIT 1;
考虑具有以下数据的表“官员”。
执行以下查询:
SELECT officer_name
FROM officers
ORDER BY officer_id DESC
LIMIT 1;
该查询将返回按Officer_id排序的最后一个Officer_name。
输出:
返回按Officer_name排序的最后一个Officer_name:
SELECT officer_name
FROM officers
ORDER BY officer_name DESC
LIMIT 1;
输出: