gpt4 book ai didi

mysql - 更新mysql中 bool 值的语法

转载 作者:行者123 更新时间:2023-11-29 19:24:27 25 4
gpt4 key购买 nike

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

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

表:温度

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=?”;

最佳答案

使用反引号来转义保留字:

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

关于mysql - 更新mysql中 bool 值的语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42247741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com