sqlite删除行数
我需要编写一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SQLite 中的所有行都有 rowid 字段,您可以使用该字段查找大于 200 的行。例如:
您还可以使用带有限制的偏移量:
使用 roqid 似乎是更好的选择。
All rows in an SQLite have rowid field, which you can use to find rows greater than 200. For example:
You could also use an offset with your limit:
using the roqid seems to be the better choice.