UPDATE REPLACE works on Phpmyadmin but does not work on Workbench

Asked

Viewed 50 times

0

I can use this code on HphpmyAdmin:

UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`, 
'src="https://www.meusite.com.br/wp-content/uploads/2014/07/tipo.gif" alt="Baixar" width="24" height="24"', 
'src="https://www.meusite.com.br/wp-content/uploads/2014/07/tipo.png" alt="Baixar" width="40" height="40"');

But when I use Workbench it generates error:

Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column.  To disable safe mode, toggle the option in Preferences -> SQL Editor and reconnect.   0.047 sec

I disabled the safe update but without success.

Could someone give me a light on how to run this REPLACE on the Workbench?

2 answers

2


Has two ways to solve for a query:

  • Include the where with the field(s) (s) that are primary key, as recommended where possible;

  • Use the command SET SQL_SAFE_UPDATES to disable SAFE_UPDATES validation for your query. In this case, turn off the validation before running the UPDATE using SET SQL_SAFE_UPDATES = 0 and then call again with SET SQL_SAFE_UPDATES = 1

Remembering that, this goes for UPDATE and DELETE.

More information in the documentation of: https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_safe-updates

  • Managed using a WHERE ;-) Thank you Ricardo.

  • @Robisonluizfernandes if the answer was helpful, be sure to accept :)

0

According to Ricardo Pontual’s response. It would be possible Using a WHERE Clause, or using the Command SET SQL_SAFE_UPDATES.

I used a WHERE Clause to allow the Bank to run.

WHERE ID != 0;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.