Android的SQLite的查询问题 [英] Android SQlite query problem

查看:100
本文介绍了Android的SQLite的查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说我有在一个SQLite database.Basically查询有点麻烦,我所要做的是从数据库中检索一堆行情,这取决于在一个列表从用户选择的作者。

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.

但有一个问题,我的SELECT语句(似乎..),我似乎无法发现它,所以如果你们中的任何好的民间能借一双眼睛我真的AP preciate吧。

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.

我的查询:

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);
}

错误:

20 04-28:05:10.685:ERROR / AndroidRuntime(25017):android.database.sqlite.SQLiteException:由近造成安东:语法错误:,在编译:SELECT引自行情WHERE auth_name =罗伯特·安东·威尔逊

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

推荐答案

您需要在你的谁的字符串单引号。

You need single quotes around your "who" string.

这篇关于Android的SQLite的查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆