String sqlUpdate = "update article set rootid ='" +rootId + "' where id =" +rootId;
"(这里是不是要有空格呢)where
如果rootid是字符串类型的话,要加上单引号('') 的,是不是这个问题呀
String sqlUpdate = "update article set rootid ='" +rootId + "' where id =" +rootId; String sqlUpdate = "update article set rootid ='"+rootId+"' where id ='"+rootId+"'";
String sqlUpdate = "update article set rootid ='" +rootId + "' where id ='" +rootId+"'";
String sqlUpdate = "update article set rootid =" +rootId + " where id =" +rootId" ";
String sqlUpdate = "update article set rootid =" +rootId + "where id =" +rootId; 空格问题,如果字段是字符类型,再加上单引号
支持7楼的 "where 改为 "空格where
上面都说完了。 String sqlUpdate = "update article set rootid =" +rootId + "where id =" +rootId;红色的地方where之前要有空格。否则连起来就错误了
正确的答案上面都说了,给LZ一个建议,在组合sql语句的时候,每一部分的前后最好都留个空格,空格在sql语句中多了可以,但是少了就不行了,但是在赋值时如" update user set name='" + this.getName + "' " 这种情况时前面的单引号后面不能加空格,后面的单引号前面不能加空格
避免sql注入啊 哥们 那样也不用考虑 拼字符串的问题了
呵呵,我拼sql都是用 ? 。。
String updatesql ="update article set rootid = " + rootid + " where id = " + rootid;你可以通过输出sql语句 : System.out.println(updatesql);或者out.println(updatesql);看看这句对不对?????
String sqlUpdate = "update article set rootid ='" +rootId + "' where id =" +rootId;
String sqlUpdate = "update article set rootid ='"+rootId+"' where id ='"+rootId+"'";
String sqlUpdate = "update article set rootid ='" +rootId
+ "' where id ='" +rootId+"'";
空格问题,如果字段是字符类型,再加上单引号
"where 改为 "空格where
String sqlUpdate = "update article set rootid =" +rootId + "where id =" +rootId;红色的地方where之前要有空格。否则连起来就错误了
: System.out.println(updatesql);或者out.println(updatesql);看看这句对不对?????
蹭点分,
找问题的时候可以把SQL语句完整打印出来,这样方便调试,节省时间,牵扯到数据库方面,报错了一般都是先确保sql语句本身没问题。
你这样生成的SQL语句把你传的值和where联在一起了,肯定不对的