I am receiving an error when I run this query, any clue what my syntax error is?
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): Caused by: android.database.sqlite.SQLiteException: near "AS": syntax error (code 1): , while compiling: SELECT CASE WHEN createduser = 112 THEN (createdplayerpts AS you AND connectedplayerpts AS them) ELSE (connectedplayerpts AS you AND createdplayerpts AS them) FROM game WHERE (turn = ?)
Try this.
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 = ?)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.