删除的行指定数量的SQLite数据库 [英] Deleting specified number of rows from SQLite database
问题描述
我想用下面的语句从数据库中删除6行,但我得到所示的错误以下
。execSQLgetWritableDatabase()(DELETE FROM tblname ORDER BY _id ASC LIMIT 6;);
错误: 致:android.database.sqlite.SQLiteException:近序:语法错误:DELETE FROM tblname
我试图重新格式化SQL以不同的方式,但我不能让它的工作。我在想什么?非常感谢您的帮助
DELETE FROM tblname WHERE`_id` IN(SELECT`_id`从tblname ORDER BY`_id` ASC LIMIT 6)
我觉得你的问题可能已经被引用了 _id
,虽然。
I am trying to remove 6 rows from the database using the following statement but i get the error shown below
getWritableDatabase().execSQL("DELETE FROM tblname ORDER BY _id ASC LIMIT 6;");
Error: Caused by: android.database.sqlite.SQLiteException: near "ORDER": syntax error: DELETE FROM tblname
I tried reformatting the SQL in different ways but i couldn't get it to work. What am i missing? Thanks a lot for your help
DELETE FROM tblname WHERE `_id` IN (SELECT `_id` FROM tblname ORDER BY `_id` ASC LIMIT 6)
I think your problem may have been quoting the _id
, though.
这篇关于删除的行指定数量的SQLite数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!