gpt4 book ai didi

sql - 与sql server中的 "top"相反,不使用order by,没有键/索引

转载 作者:行者123 更新时间:2023-12-02 14:12:40 26 4
gpt4 key购买 nike

我想从 SQL Server 表中检索最后 10 个结果。我希望它们是最后插入的 10 条记录,我该怎么做?

我想写select Bottom 10 * from mytable,但这不存在(据我所知)。

我想要插入最后 10 行。没有时间戳。

最佳答案

你不能。

根本无法保证 select * from mytable 返回的最后 10 条记录将是最后插入的 10 条记录。没有使用默认顺序。

您需要在反射(reflect)插入顺序的适当列上使用 ORDER BY

关于sql - 与sql server中的 "top"相反,不使用order by,没有键/索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8712000/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com