Android Sqllite:无法解决查询中的语法错误

时间:2017-06-13 06:05:06

标签: sql sqlite

我在每个标签页上更新购物车,代码我更新了购物车项目,但在语法上显示错误。

else continue

1 个答案:

答案 0 :(得分:3)

您正在添加AND而不是comma,删除可以解决问题。

将查询更改为:

String sql2 = "UPDATE " + DbConstants.TABLE_CART + " SET " +
        DbConstants.COLUMN_MEMBER + " = '" + cartItemBean.getCOLUMN_MEMBER() + "', "
        + DbConstants.COLUMN_DATE + " = '" + cartItemBean.getCOLUMN_DATE() + "', "
        + DbConstants.COLUMN_TIME + " = '" + cartItemBean.getCOLUMN_TIME() + "', "
        + DbConstants.COLUMN_TOTAL_PRICE + " = '" + cartItemBean.getCOLUMN_TOTAL_PRICE() + "' "
        + " WHERE " +
        DbConstants.COLUMN_PACKID + " = '" + cartItemBean.getCOLUMN_PACKID() + "' AND "
        + DbConstants.COLUMN_USERID + " = '" + cartItemBean.getCOLUMN_USERID() + "'";

检查此tutorial中的示例。