gpt4 book ai didi

android - SQLite in operator in query()

转载 作者:IT王子 更新时间:2023-10-29 06:23:49 24 4
gpt4 key购买 nike

我是这样调用SQLite的

String[] args = new String[]{"(A,B)"}
Cursor cur = db.query("tab1", null, "name in ?", args, null, null, null);

并接收异常:

android.database.sqlite.SQLiteException: near "?": syntax error: , while compiling: SELECT * FROM tab1 WHERE name in ?

如何在 query() 中使用 in 运算符?

我已经试过了

String[] args = new String[]{"('A','B')"}

最佳答案

String[] args = new String[]{A,B} // if A, B are variables
String[] args = new String[]{"A","B"}
Cursor cur = db.query("tab1", null, "name in (?,?)", args, null, null, null);

关于android - SQLite in operator in query(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16295432/

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