您好我需要一些帮助才能使我的mysql正确无误。 我需要选择一行具有最大'var'列值。 这就是我现在所拥有的,但它没有给出最大值
SELECT a.* FROM `table` AS a GROUP BY a.var HAVING a.var = MAX(a.var) AND `code` = '1' AND `type` = '0';
答案 0 :(得分:3)
您可以将ORDER BY
与LIMIT 1
:
SELECT col1, col2, ..., coln
FROM `table`
WHERE `code` = '1' AND `type` = '0'
ORDER BY `var` DESC
LIMIT 1
答案 1 :(得分:0)
这可能就是您所需要的:
SELECT MAX(vari)
FROM TABLE
WHERE `code` = '1' AND `type` = '0'