sqlite删除行数

发布于 2024-12-09 00:19:45 字数 273 浏览 0 评论 0原文

我需要编写一个 SQLlite 查询,该查询将从表中删除 200 以上的行。我想这会起作用:

DELETE FROM [tbl_names] WHERE count(*) > 200

但这给了我:滥用聚合函数 count()

我知道有一个可以使用的限制子句,但是如果我use:

DELETE FROM [tbl_names] LIMIT 200

看起来会删除前 200 行。

I need to write a SQLlite query that will delete rows from a table above 200. I was thinking this would work:

DELETE FROM [tbl_names] WHERE count(*) > 200

but that gives me: misuse of aggregate function count()

I know there is a limit clause I can use, but if I use:

DELETE FROM [tbl_names] LIMIT 200

that looks like it will delete the first 200 rows.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷心人i 2024-12-16 00:19:45

SQLite 中的所有行都有 rowid 字段,您可以使用该字段查找大于 200 的行。例如:

DELETE FROM [tbl_names] WHERE rowid > 200

您还可以使用带有限制的偏移量:

DELETE FROM [tbl_names] LIMIT 10000 offset 200

使用 roqid 似乎是更好的选择。

All rows in an SQLite have rowid field, which you can use to find rows greater than 200. For example:

DELETE FROM [tbl_names] WHERE rowid > 200

You could also use an offset with your limit:

DELETE FROM [tbl_names] LIMIT 10000 offset 200

using the roqid seems to be the better choice.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文