mysql多查询得到错误#1064 -

时间:2016-08-31 10:37:17

标签: mysql

需要帮助

当我运行此查询时,我得到一个错误的简单更新查询,如果逐个运行,则工作正常。

update wp_posts 
set post_title = CONCAT(post_title,' Keyboard') 
where id = 67096 and NOT post_title like '%keyboard%'

update wp_posts 
set post_title = CONCAT(post_title,' Keyboard') 
where id = 67079 and NOT post_title like '%keyboard%'

update wp_posts 
set post_title = CONCAT(post_title,' Keyboard') 
where id = 67072 and NOT post_title like '%keyboard%'

我得到这个错误的消息

  

1064 - 您的SQL语法出错;查看与您的MySQL服务器版本对应的手册,以便在'update wp_posts set post_title = CONCAT(post_title,'Keyboard')附近使用正确的语法,其中id = 67131'在第2行

重要的是,当我逐一运行查询行时,它完美运行!如果我一行一行地运行它们,则查询失败

请帮我理解问题

谢谢Asaf

1 个答案:

答案 0 :(得分:1)

如果同时运行多个sql queries,则在每次sql查询后添加分号(;),否则会出错。

立即尝试。

update wp_posts set post_title = CONCAT(post_title,' Keyboard') where id = 67096 and NOT post_title like '%keyboard%';
update wp_posts set post_title = CONCAT(post_title,' Keyboard') where id = 67079 and NOT post_title like '%keyboard%';
update wp_posts set post_title = CONCAT(post_title,' Keyboard') where id = 67072 and NOT post_title like '%keyboard%';

希望它会有所帮助。