且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL查询以从表中获取最新记录

更新时间:2023-01-27 17:39:33

尝试以下操作:

Try this one:

SELECT TOP 1 * FROM [TABLENAME] ORDER BY id DESC



如果这解决了您的问题,请标记为答案并投票5

问候,
爱德华(Eduard)



Please mark as answer and vote 5 if this solved your problem

Regards,
Eduard


其他几种方式

如何使用SQL Server读取最后一行 [ ^ ]
Here other couple of ways

how to read the last row with SQL Server[^]


至少要获取最新记录,您必须具有唯一值列,这将帮助您获取最新行.这是语法

To get the latest record at least you have A Unique Valued Column, which will help you to get latest row. here is syntax

SELECT TOP 1 * FROM table_Name ORDER BY unique_column DESC