2016-08-31 65 views
0

幫助需要mysql的多查詢得到ERR#1064 -

當我運行此查詢我正在一個犯錯只是簡單的更新查詢,如果是運行一個接一個工作正常。

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服務器版本使用附近的正確語法手冊「更新wp_posts設置POST_TITLE = CONCAT(POST_TITLE,」鍵盤「),其中id = 67131」在第2行

重要的事情是,當我一個一個地運行查詢行,它完美的工作!如果我運行他們的行中的所有行的查詢失敗

請幫助我理解這個問題

感謝阿薩夫

+1

在每個Update語句末尾添加';' – Jens

回答

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%'; 

希望它能幫上忙。

+0

THanks太簡單了! –

+0

請接受答案並投票。 :) – Pirate