mysql workbench cannot : update where like - mysql

Normally i can update my rows w/ queries such as
UPDATE t SET col1='123' WHERE col2 LIKE '%abc%';
or
UPDATE mydb.t SET col1='123' WHERE col2 LIKE '%abc%';
But with MySQL Workbench I seem to only be able to SELECT but cannot UPDATE the tables with queries.
Does anyone know a fix for working with workbench?
FIX
To disable safe mode, toggle the option in Preferences -> SQL Editor -> Query Editor and reconnect.

Mysql workbench usually disables by default updates without a where clause, and/or updates that hit more than a configured X elements.
When you try to update and fail, if it is how I think it is, then pay attention to the error message, as it tells you exactly which setting to change.

Related

How to delete when primary key contains two columns, and using safe mode

My table is created like this:
CREATE TABLE test(
num1 INT,
num2 INT,
PRIMARY KEY(num1, num2)
);
what should my delete query look like?
using
DELETE FROM test WHERE num1=1 AND num2=2;
only result in this error message:
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.
Also, before you ask, I do know how to turn safe update mode off, but that does not answer my question.
I've seen some other Stack Overflow posts where people complain that MySQL Workbench is blocking them from performing safe updates inappropriately.
But I just tried it with your table, both with the PK columns and with a non-key column. When safe mode is enabled, it blocks me from doing updates via non-key column, as it should. But I don't get the error you described.
I'm using MySQL Workbench 6.3.8 and MySQL Server 8.0.0-dmr.
Perhaps this is a bug in an old version of MySQL or an old version of MySQL Workbench.
Updated mysql and the error is gone.
what a waste of my time.

MySQL error code: 1175 during UPDATE (MySQL-Workbench vs. console)

Am very aware of that this issue can be resolved with disabling safe update mode enabled (e.g. see here: MySQL error code: 1175 during UPDATE in MySQL Workbench). However, I do not wish to disable safe update mode (and there are many many solutions that propose this).
Similarly, I am aware that setting the WHERE clause to KEY-value that matches everything is supposed to work. However, doesn't appear to work on mysql-workbench - at least not the way I hoped (or the way it did work on the console).
For example, the following didn't work on mysql-workbench (but did on the console):
UPDATE FUEL_SOURCES AS FS
INNER JOIN
FUEL_CATEGORY FC ON FC.FUEL_CATEGORY = FS.FUEL_CATEGORY
SET
FS.FUEL_CATEGORY_ID = FC.ID
WHERE
FC.ID <> 0 AND FS.ID <> 0
...If I explicitly / exactly set the ID's (e.g. WHERE FC.ID = 20 AND FS.ID <> 10 for example) it would work in mysql-workbench. But doing this would involve iterating through every key-pair combination.
Be intereted to know what is causing this behaviour, or if I am doing something horribly wrong. Using mysql-workbench 6.3
From https://dev.mysql.com/doc/workbench/en/workbench-faq.html#faq-workbench-delete-safe
By default, Workbench is configured to not execute DELETE or UPDATE
queries that do not include a WHERE clause on a KEY column.
Such configuration prevents you from deleting or updating table mistakenly, since you are doing a batch update on data without a key.
To resolve this, as you may be already aware the following options.
Open your Workbench Preferences, select the SQL Editor section, and disable the following preference: "Safe Updates" - Forbid UPDATEs and DELETEs with no key in WHERE clause or no LIMIT clause.
Run SET SQL_SAFE_UPDATES=0;
If you are using workbech, you can first execute
SET SQL_SAFE_UPDATES = 0;
And then execute delete statement
If you want to still update your data with safe update on, you must retool your where clause so that it includes references to the table's primary key(s). See this page.

Error Code: 1175. You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column

I am trying to run an update query where actual id looks like 1273106/2 using the following query but running into below error,can anyone help how to fix it?
UPDATE ids.id_submit_table SET picked_bit='1'
WHERE (id like '1273106')
Row looks like below
126 1273106/2 AL.BH.1.1.1 SU_CNSS_BT_FM_AL.BH.1.1.1 username 0 0
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 Queries and reconnect. 0.000 sec
This error appears because safe update mode requires key to update/delete with where clause, you can use
SET SQL_SAFE_UPDATES=0;
Before executing the query or if you want to avoid this situation in future please make sure update/delete by using key with where clause
try this for fix problem.
To permanently disable safe update mode in MySQL Workbench 8.0 you should do the following:
Go to Edit --> Preferences.
Click "SQL Editor" tab and uncheck "Safe Updates" (rejects UPDATEs and DELETEs with no restrictions) check box.
Query --> Reconnect to Server.
This is MySQL Workbench issue, not MySQL itself. You can try via any other MySQL client or you can toggle safe queries off in Workbench Preferences.
click on edit and find Preferences.
find SQL editor click on it, go to the bottom, and uncheck
click on ok.
now goto server, find the startup and shut down, stop the server and start again
This is MYSQL workbench ISSUE!!!
Simply open mysql command line and there place syntax later execute there. It automatically change in mysql work bench also.

Getting error when tried to update a table using stored procedure in mysql

UPDATE IDConfig SET FemaleID = FemaleID + 1;
Getting Error like 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.
Your SQL tool uses this mechanism to tell you that you are about to update ALL records in a table. Normally you have a WHERE clause to limit the data that should be updated.
So to really update ALL records change that option in the configuration or use a WHERE clause to limit your data to update.
You probably can trick your tool with this query
UPDATE IDConfig
SET FemaleID = FemaleID + 1
WHERE 1 = 1

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
To disable it just for the current session run:
SET SQL_SAFE_UPDATES=0;
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)
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.
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);