Sqlite如何删除表的最后添加条目
我正在尝试删除表中最后添加的条目:
DELETE FROM notes ORDER BY created_at DESC LIMIT 1
这只会导致以下错误:
near "ORDER": syntax error
为什么我会收到此错误? (notes
存在并且其中有记录!)
I'm trying to delete the last added entry of a table:
DELETE FROM notes ORDER BY created_at DESC LIMIT 1
This just causes the following error:
near "ORDER": syntax error
Why might I be getting this error? (notes
exists and has records in it!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个
Try this
请注意,这不会限制删除的行数。如果 max(created_at) 处有多于一行,这将删除所有行,因为您指定的主题不存在(表的最后添加条目)。
Watch out, this will not limit the number of rows deleted. If there are more than one row at max(created_at), this will delete all of them because the subject you specified does not exist (last added entry of a table).