0

I tried to update boolean values in MySql database but i receive error :

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

Table : 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;

Syntax : "update tempemp set add=?,edit=?,delete=?,view=? where id=?";

Roman C
  • 49,761
  • 33
  • 66
  • 176
Parth Patel
  • 799
  • 1
  • 13
  • 20

1 Answers1

1

Use backquotes to escape reserve word:

 update tempemp set `add`=0, `edit`=0, `delete`=0, `view`=1 where id=3;
Blank
  • 12,308
  • 1
  • 14
  • 32