Android SQlite查询问题
正如标题所说,我在 sqlite 数据库查询时遇到了一些麻烦。基本上,我想要做的是从数据库中检索一堆引号,具体取决于从列表中的用户中选择的作者。
但是我的 SELECT 语句有一个问题(看起来..),我似乎无法发现它,所以如果你们中的任何一个好心人可以借一双眼睛,我将非常感激。
我的查询:
public Cursor getQuotes(int position){
String who = authorName[position];
return qmDB.query(QUOTES_TABLE, new String[]{
KEY_QUOTE
},
KEY_AUTHNAME + "=" + who,
null,
null,
null,
null);
}
错误:
04-28 20:05:10.685:错误/AndroidRuntime(25017):引起:android.database.sqlite.SQLiteException:靠近“Anton”:语法错误:,编译时:从引号中选择引用 WHERE auth_name =罗伯特·安东·威尔逊
As the title says I am having a little trouble with a query on an sqlite database.Basically, what I am trying to do is retrieve a bunch of quotes from the database, depending on the author chosen from user in a list.
But there is a problem with my SELECT statement(it seems..), and I can't seem to spot it, so if any of you good folk could lend a pair of eyes I would really appreciate it.
My query:
public Cursor getQuotes(int position){
String who = authorName[position];
return qmDB.query(QUOTES_TABLE, new String[]{
KEY_QUOTE
},
KEY_AUTHNAME + "=" + who,
null,
null,
null,
null);
}
Error:
04-28 20:05:10.685: ERROR/AndroidRuntime(25017): Caused by: android.database.sqlite.SQLiteException: near "Anton": syntax error: , while compiling: SELECT quote FROM Quotes WHERE auth_name=Robert Anton Wilson
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要用单引号将“who”字符串引起来。
You need single quotes around your "who" string.