mysql select largest value code example
Example 1: mysql get max value and id
SELECT a.id, a.rev, a.contents
FROM YourTable a
INNER JOIN (
SELECT id, MAX(rev) rev
FROM YourTable
GROUP BY id
) b ON a.id = b.id AND a.rev = b.rev
Example 2: mysql select smaller of two values
SELECT LEAST(2,0);