-2

我在 sql 中有一个表,我想显示表的最后一行的列,这怎么可能?我用过SELECT TOP 1 id FROM .$table ORDER BY id DESC但没有答案。

4

2 回答 2

0
  • In MS Access:

    SELECT TOP 1 id FROM $table ORDER BY id DESC
    
  • In MySQL:

    SELECT id FROM $table ORDER BY id DESC LIMIT 1
    
  • In Oracle:

    SELECT id FROM $table WHERE ROWNUM <=1 ORDER BY id
    
  • Or, you can do this: (based on Joop Eggen's comment)

    SELECT MAX(id) FROM $table
    

Where $table is the name of your table.

You may also want to check this article on w3schools.

于 2013-07-24T12:51:43.053 回答
0

尝试将 LIMIT 设置为 1 喜欢

SELECT TOP 1 id FROM $table ORDER BY id DESC LIMIT 1

确保 $table 是您的表名。

于 2013-07-24T12:40:03.197 回答