Momo1199 2013-04-25 07:29 采纳率: 0%
浏览 4103
已采纳

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 = ?)
  • 写回答

2条回答

  • balmy 2013-04-25 11:28
    关注

    类似这种SQL语法错误可以把你的语句先放到sql工具中执行下,首先确保sql语句本身没错,再检查你的代码有没有笔误,类似缺少逗号,括号不匹配这些。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用