rym
rym

Reputation: 33

error appear when I execute a SQL request

I have a SQL request that I can't execute ,this error appear:

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

My request:

update customfieldvalue
set stringvalue="****"
where customfieldvalue.customfield IN 
(select customfield.id 
from customfield 
where customfield.cfname="Resoltion" 
and customfieldvalue.issue=12345);

how can I fix this problem,because in my production environment I can't do this manipulation? PS:I'am using mysql

Upvotes: 3

Views: 5090

Answers (4)

user2531028
user2531028

Reputation: 2275

SET SQL_SAFE_UPDATES=0;
update customfieldvalue
set stringvalue="****"
where customfieldvalue.customfield IN 
(select customfield.id 
from customfield 
where customfield.cfname="Resoltion" 
and customfieldvalue.issue=12345);

Upvotes: 0

Casebash
Casebash

Reputation: 118792

To disable it just for the current session run:

SET SQL_SAFE_UPDATES=0;

Upvotes: 2

DaveE
DaveE

Reputation: 3637

If you can't turn off safe update in production, you'll need to rework your query to involve at least one key column in customfieldvalue. Without it, you'll be performing a table scan; using key column #1, you might end up with the logical equivalent ( WHERE customfieldvalue.keycol1 IS NOT NULL ), but that will satisfy the safe update constraints.

Upvotes: 0

Kieren Johnstone
Kieren Johnstone

Reputation: 42003

To fix this problem:

To disable safe mode: Toggle the option in Preferences -> SQL Editor -> Query Editor and reconnect.

The cause:

You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

(Did you read the message? It explains everything)

Upvotes: 0

Related Questions