程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> sqlite-Android SQLite查詢報錯

sqlite-Android SQLite查詢報錯

編輯:編程綜合問答
Android SQLite查詢報錯

在運行查詢語句時,報錯語法錯誤:

inal 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 = ?)

最佳回答:


類似這種SQL語法錯誤可以把你的語句先放到sql工具中執行下,首先確保sql語句本身沒錯,再檢查你的代碼有沒有筆誤,類似缺少逗號,括號不匹配這些。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved