0

运行此查询时收到错误消息,是否知道我的语法错误是什么?

final Cursor c = getContentResolver().query(
Provider.GAME_URI, new String[]{"CASE WHEN " +DBHelper.COLUMN_CRE_USER + " = " + preferences.getInt(LoginScreen.ID, 0) + " THEN (" + DBHelper.COLUMN_CRE_PTS + " AS you AND " + DBHelper.COLUMN_CON_PTS + " AS them) ELSE (" + DBHelper.COLUMN_CON_PTS + " AS you AND " + DBHelper.COLUMN_CRE_PTS + " AS them)"},"turn = ?",
new String[] { preferences.getInt(LoginScreen.ID, 0) + ""}, null);

04-24 19:57:48.345: E/AndroidRuntime(18775): 由: android.database.sqlite.SQLiteException: 靠近 "AS": 语法错误 (代码 1): , 编译时: SELECT CASE WHEN createduser = 112 THEN (createdplayerpts as you and connectedplayerpts as they) ELSE (connectedplayerpts as you and createdplayerpts as they) FROM game WHERE (turn = ?)

4

1 回答 1

1

尝试这个。

SELECT 
    CASE WHEN createduser = 112 THEN createdplayerpts ELSE connectedplayerpts END AS you,
    CASE WHEN createduser = 112 THEN connectedplayerpts ELSE createdplayerpts END AS them
FROM 
    game WHERE (turn = ?)
于 2013-04-25T03:21:18.907 回答