SQL修改语句的错误总结
在人口普查系统中出现了一个错误,在修改信息时,性别成为了必选,不修改的话,其他信息无法修改,经过反复测试后发现是SQL语句写错了(大哭)
正确的SQl语句应为
String sql = "update person\n"+
"set hu_bie = ?,\n "+
"idc = ?,\n " +
"name = ?,\n"+
"jiao_yu = ?,\n"+
"lei_xing = ?,\n"+
"mian_ji = ?,\n"+
"min_zu = ?,\n"+
"shu_mu = ?,\n"+
"sex = ?\n" + 这个\n不可少
"where id = ?";
之前的错误语句为:
String sql = "update person\n"+
"set hu_bie = ?,\n "+
"idc = ?,\n " +
"name = ?,\n"+
"jiao_yu = ?,\n"+
"lei_xing = ?,\n"+
"mian_ji = ?,\n"+
"min_zu = ?,\n"+
"shu_mu = ?,\n"+
"sex = ?" + 关键在于这句,不加\n,sex就变成了必须修改的项目!
"where id = ?";