3 回答
TA贡献1815条经验 获得超10个赞
price 应该是数值,不需要加‘号,
price = " + menu.getPrice() + "'," (多了一个单引号)
amount = '" + menu.getAmount() + "'," + 也多了一个单引号
String sql = "UPDATE [menu].[chifood] SET " +
"id = '" + menu.getName() + "'," +
"price = " + menu.getPrice() + "," +
"amount = '" + menu.getAmount() + "'," +
"WHERE id = '" + menu.getId().trim() +"'";
TA贡献1862条经验 获得超7个赞
我觉得应该是:
"UPDATE menu.chifood t SET " +
"t.name = '" + menu.getName() + "'," +
" t.price = " + menu.getPrice() + "', " +
" t.amount = '" + menu.getAmount() + "'," +
"WHERE t.id = '" + menu.getId().trim() +"'";
你的"id = '" + menu.getName() + "'," 这个东西id你是使用什么规则的?怎么会把get到的name插入到id上去?
表名上不需要引起来吧。
TA贡献1797条经验 获得超4个赞
改为
String sql = "UPDATE menu.chifood SET " +
"id = '" + menu.getName() + "'," +
"price = "' + menu.getPrice() + "'," +
"amount = '" + menu.getAmount() + "' " +
"WHERE id = '" + menu.getId().trim() +"'";
添加回答
举报