如何从我上次获取的记录中获取最后更新的记录

时间:2022-09-25 22:13:23

how to store last fetched record info in sql and how to pass the same condition in sql ? i'm having LastModifiedOn field in table (Using C#)

如何在sql中存储最后获取的记录信息以及如何在sql中传递相同的条件?我在表中有LastModifiedOn字段(使用C#)

1 个解决方案

#1


0  

if your table doesn't have a inserted_date column (or something like that), I think the solution would be to

如果你的表没有inserted_date列(或类似的东西),我认为解决方案是

SELECT * from table where ID not int(ALL_THE_IDS_OF_THE_ITEMS_IN_XML)

SELECT * from表,其中ID不是int(ALL_THE_IDS_OF_THE_ITEMS_IN_XML)

But that will be a very coslty method since you need to parse your xml and retrieve all the IDs.

但这将是一个非常常见的方法,因为您需要解析您的xml并检索所有ID。

The best solution is to have an inserted_date column in your table then after your every select, you store the time at that current fetch. something like:

最好的解决方案是在表中插入一个inserted_date列,然后在每次选择后,将时间存储在当前的fetch中。就像是:

SELECT *, getdate() as SelectDate from table

SELECT *,getdate()作为表中的SelectDate

you will then store that SelectDate somewhere so that it will be referenced on your next select:

然后,您将把SelectDate存储在某处,以便在下次选择时引用它:

NOTE: SelectDate reflects the actual time of your previous query.

注意:SelectDate反映上一次查询的实际时间。

SELECT *, getdate() as SelectDate from table where inserted_date > 'YOUR_PREVIOUS_SelectDate'

SELECT *,getdate()作为表中的SelectDate,其中inserted_date>'YOUR_PREVIOUS_SelectDate'

Accordingly, you just use the latest SelectDate for your next query.

因此,您只需使用最新的SelectDate进行下一次查询。

#1


0  

if your table doesn't have a inserted_date column (or something like that), I think the solution would be to

如果你的表没有inserted_date列(或类似的东西),我认为解决方案是

SELECT * from table where ID not int(ALL_THE_IDS_OF_THE_ITEMS_IN_XML)

SELECT * from表,其中ID不是int(ALL_THE_IDS_OF_THE_ITEMS_IN_XML)

But that will be a very coslty method since you need to parse your xml and retrieve all the IDs.

但这将是一个非常常见的方法,因为您需要解析您的xml并检索所有ID。

The best solution is to have an inserted_date column in your table then after your every select, you store the time at that current fetch. something like:

最好的解决方案是在表中插入一个inserted_date列,然后在每次选择后,将时间存储在当前的fetch中。就像是:

SELECT *, getdate() as SelectDate from table

SELECT *,getdate()作为表中的SelectDate

you will then store that SelectDate somewhere so that it will be referenced on your next select:

然后,您将把SelectDate存储在某处,以便在下次选择时引用它:

NOTE: SelectDate reflects the actual time of your previous query.

注意:SelectDate反映上一次查询的实际时间。

SELECT *, getdate() as SelectDate from table where inserted_date > 'YOUR_PREVIOUS_SelectDate'

SELECT *,getdate()作为表中的SelectDate,其中inserted_date>'YOUR_PREVIOUS_SelectDate'

Accordingly, you just use the latest SelectDate for your next query.

因此,您只需使用最新的SelectDate进行下一次查询。