MAX()
MySQL 函式 Function: MAX()
最大数字资料
SELECT
*
FROM
payments
WHERE
amount = (
SELECT
MAX(amount)
FROM
payments
);
SELECT
*
FROM
payments
ORDER BY
amount DESC
LIMIT 1;
每个使用者最新日期资料
SELECT
a.*
FROM
messages a
INNER JOIN (
SELECT name, max(other_col) AS other_col
FROM messages
GROUP BY name
) AS b
ON a.name = b.name
AND a.other_col = b.other_col