Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 近;选择";:语法错误(代码1)_Android_Sqlite_Android Database - Fatal编程技术网

Android 近;选择";:语法错误(代码1)

Android 近;选择";:语法错误(代码1),android,sqlite,android-database,Android,Sqlite,Android Database,我面临的问题是: Caused by: android.database.sqlite.SQLiteException: near "SELECT": syntax error (code 1): , while compiling: SELECT tags FROM appDb_table_project WHERE SELECT DISTINCT tags 我有: public static final String DB_NAME = "appDbProject"; public sta

我面临的问题是:

Caused by: android.database.sqlite.SQLiteException: near "SELECT": syntax error (code 1): , while compiling: SELECT tags FROM appDb_table_project WHERE SELECT DISTINCT tags
我有:

public static final String DB_NAME = "appDbProject";
public static final int DB_VERSION = 1;
public static final String DB_TABLE = "appDb_table_project";

public static final String COLUMN_ID = "_id";
public static final String COLUMN_NAME = "name";
public static final String COLUMN_DESCRIPTION = "description";
public static final String COLUMN_TAGS = "tags";

public SQLiteDatabase mDB;
public Cursor getTags() {
    String[] column = new String[] { COLUMN_TAGS };
    //return mDB.query(DB_TABLE, column, "SELECT DISTINCT tags", null, null, null, null);
    //return mDB.query(true, DB_TABLE, new String[] { COLUMN_TAGS }, null, null, COLUMN_TAGS, null, null, null);
    //String query ="SELECT DISTINCT tags FROM appDb_table_staff";
    //return mDB.rawQuery(query, null);
    return mDB.query(true, DB_TABLE, new String[] { COLUMN_TAGS }, null, null, COLUMN_TAGS, null, null, null);
}
我试图对字段“tags”中的数据使用SELECT DISTINCT语句,并将其放入字符串[],但我没有得到

Cursor cursor = db.getTags();
    String[] array = new String[cursor.getCount()];
    int i = 0;
    while (cursor.moveToNext()) {
        String tag = cursor.getString(cursor.getColumnIndex("tags"));
        array[i] = tag;
        i++;
    }
    String[] from = array;
    int[] to = new int[] { R.id.textViewTags };
我尝试了不同的选项,但在这一行和我的方法“getTags”中,我永远都会遇到这个错误:

我做错了什么

upd:

实际执行的代码: 尝试添加“空格”


只需更改以下行:

SELECT tags FROM appDb_table_project WHERE SELECT DISTINCT tags


我做错了什么?
此:
在其中选择不同的标记
错误表与代码不匹配。显示实际执行的代码。我可以读取错误的文本,但仍然无法找出错误所在。我试着像其他人那样做,但仍然没有发生任何事情。@CL我的问题中有一个代码,导致了一个错误
Cursor Cursor=db.getTags()
和我的方法
getTags()
中未注释的行
getTags()
无法生成此错误。
public Cursor getTags() {
String[] column = new String[] { COLUMN_TAGS };
//return mDB.query(DB_TABLE, column, " SELECT DISTINCT tags ", null, null, null, null);
//return mDB.query(true, DB_TABLE, new String[] { COLUMN_TAGS }, null, null, COLUMN_TAGS, null, null, null);
//String query =" SELECT DISTINCT tags FROM appDb_table_staff ";
//return mDB.rawQuery(query, null);
return mDB.query(true, DB_TABLE, new String[] { COLUMN_TAGS }, null, null, COLUMN_TAGS, null, null, null);
 }
SELECT tags FROM appDb_table_project WHERE SELECT DISTINCT tags
SELECT tags FROM appDb_table_project