balage90
balage90

Reputation: 87

How to use replace to update the column items

I'd like to change the ',' char into '.' at one of my column . I can make the replace syntax but it just a view. And i want to update it for the all records!

select cast(replace(egysegar,',','.')as decimal (10,3)) from temporary

i'll tried the next one to update

UPDATE temporary set egysegar = replace(egysegar,',','.') where egysegar is not null

but after i get an error :

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 Queries and reconnect.

Upvotes: 0

Views: 102

Answers (2)

Adrian Ber
Adrian Ber

Reputation: 21370

Most probably you're using MySQL Workbench and you actually have to disable the safe mode or add in the WHERE clause a key column, exactly as it says in the message.

Or you can run SET SQL_SAFE_UPDATES=0; before your update query.

Upvotes: 1

naveen goyal
naveen goyal

Reputation: 4629

Possible answer is that MySql run with safe-updates option. It mean you can't update or delete record without key primary key on where clause.

SET SQL_SAFE_UPDATES=0;

or use primary key in where clause

Upvotes: 0

Related Questions