gpt4 book ai didi

android - SQLite 异常 : near "ORDER" while compiling

转载 作者:行者123 更新时间:2023-11-29 15:03:27 25 4
gpt4 key购买 nike

我试图从数据库表中删除最后插入的项目,但总是出现 SQLiteException: near "ORDER"syntax error (code 1)

android.database.sqlite.SQLiteException: near "ORDER": syntax error (code 1): , while compiling: delete from pending where url = 'server' and mobile_id = '2331' and sent = '0' ORDER BY id DESC LIMIT 1

使用以下查询:

db.execSQL("delete from pending where url = 'server' and mobile_id = '" + string + "' and sent = '0' ORDER BY id DESC LIMIT 1");

最佳答案

使用嵌套查询如下。

db.execSQL("delete from pending where TABLE_ID = (SELECT TABLE_ID from pending where url = 'server' and mobile_id = '" + string + "' and sent = '0' ORDER BY id DESC LIMIT 1"));

TABLE_ID 应该是挂起表的唯一键 ID。

关于android - SQLite 异常 : near "ORDER" while compiling,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40990504/

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