SQL查询以从表中获取最新记录 [英] SQL Query to get the latest record from the table

查看:88
本文介绍了SQL查询以从表中获取最新记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

有人可以给我查询从表中选择最新记录吗?

即已插入表中的最新记录.


感谢和问候,

Dear All,

Can any one please give me the query to select the latest record from the table?

i.e., most recent record which has been inserted into the table.


Thanks and Regards,

推荐答案

尝试以下操作:

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 


这篇关于SQL查询以从表中获取最新记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆