查找记录最高的字段

时间:2011-02-14 17:59:43

标签: sql

我有这张桌子:

server_records:id int(AUTO_INCREMENT),record int,time int

如果我想获得最高记录的领域,我该怎么做?

SELECT `record` FROM `server_records` WHERE `record` = highest?!

2 个答案:

答案 0 :(得分:2)

SQL Server:

SELECT TOP 1 * FROM server_records
ORDER BY record desc

MySQL的:

SELECT * FROM server_records
ORDER BY record desc
LIMIT 1;

答案 1 :(得分:2)

最高记录,而不是ID,是吗?

SELECT MAX(record)
  FROM server_records

或者,如果您想要所有字段:

SELECT *
  FROM server_records
    WHERE record = 
      ( SELECT MAX(record)
          FROM server_records
      )