更新mysql中布尔值的语法

时间:2017-02-15 11:12:35

标签: mysql

我尝试更新MySql数据库中的布尔值,但收到错误:

com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'add=0, edit=0, delete=0, view=1 where id=3' at line 1

表:tempemp

DROP TABLE IF EXISTS `struts`.`tempemp`;
CREATE TABLE  `struts`.`tempemp` (
`id` int(10) unsigned NOT NULL auto_increment,
`role` varchar(45) NOT NULL,
`add` tinyint(1) NOT NULL default '0',
`edit` tinyint(1) NOT NULL default '0',
`delete` tinyint(1) NOT NULL default '0',
`view` tinyint(1) NOT NULL default '0',
 PRIMARY KEY  (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

语法:“update tempemp set add =?,edit = ?, delete =?,view =?where id =?”;

1 个答案:

答案 0 :(得分:0)

使用反引号来逃避保留字:

 update tempemp set `add`=0, `edit`=0, `delete`=0, `view`=1 where id=3;