MySQL Replace Will Not Replace - mysql

I feel like I'm loosing it here, this exact query used to work just fine but now it matches rows but won't change any of them, I've disabled safe updates in Workbench and even tried from CLI and same result, did something change in the REPLACE function that I'm not aware of?
Tried both ways just incase:
update MyVideos116.path set strPath = replace(strPath,'smb://STORAGESRV-VM/','smb://WMHomeStorage/')
update MyVideos116.path set strPath = replace(strPath,'smb://STORAGESRV-VM/','smb://WMHomeStorage/') WHERE strPath LIKE '%STORAGESRV-VM%';
Result is the same with the exception that with the WHERE statement I get a few less results:
0 row(s) affected Rows matched: 1258 Changed: 0 Warnings: 0
0 row(s) affected Rows matched: 1247 Changed: 0 Warnings: 0

Ugh, sorry it was the case of the STORAGESRV-VM which in the tables is StorageSrv-VM

Related

MySQL / HeidiSQL - affected rows in log is 0 but rows have definitely been affected

I'm updating a a large number of rows (~168k) with an UPDATE query that contains various JOINS.
(i changed the field and table names, but the logic of the query stays the same)
UPDATE
table_a
JOIN table_b on table_a.field1 = table_b=field1
JOIN table_c on table_b.field2 = table_c.field2
JOIN table_d on table_c.field3 = table_d.field3
JOIN table_e on table_d.field4 = table_e.field4
SET
table_a.date_field = DATE_ADD(table_a.date_field, INTERVAL 12 MONTH)
WHERE
table_a.checkfield IS NOT NULL
AND table_a.date_field >= "2017-07-05"
AND table_e.statefield != "DEU"
AND
(
table_c.statusfield1 IN (2,3,9) OR (table_c.statusfield1 = 1 AND table_c.statusfield2 = 1 AND table_c.statusfield3 IS NULL)
)
I'm a 100% sure this update query affected about 167k rows and checked it already in the database, but the mysql query log in HeidiSQL 9.5.0.5196 said:
"/* Affected rows: 0 Found rows: 0 Warnings: 0 Duration for 1 query: 52,984 sec. */"
I already ran this query limited to only 4 or 5 items and there the affected row count was correct, but if i run the whole update query the row count is alway zero.
Is this a known bug in HeidiSQL or my Percona/MySQL Version?
The system:
Server version: 5.6.40-84.0 - Percona Server (GPL), Release 84.0, Revision 47234b3, Server OS: debian-linux-gnu, HeidiSQL Version:9.5.0.5196

Mysql REPLACE resulted in 0 values on all rows

I've used the following SQL query in a MySQL database to replace part of a string in a cell:
UPDATE TEST.database2014 SET together1 = REPLACE(together1, "/1900", "20")
For some reason all the rows (225,000!) have now a value of 0.
This is the message which I got:
/* Affected rows:225,000 Found rows: 0 Warnings: 0 Duration for 1 query: 16,888 sec. */
ADDITIONAL INFORMATION:
data example contained in field together1:
TESTING^^^19/01/2014^^
Is there a known reason for this happening?
I find it strange that if no matches where found it converted all values to 0 anyway.
I think that you must use this:
UPDATE TEST.database2014 SET together1 = REPLACE(together1, "/19", "/20") WHERE togheter1 LIKE '%/19%'
if you want to upate all year 1900 to 2000

MySQL equal operator truncates values and does not work as expected

I've just discovered a strange behaviour of MySQL, about the equal operator.
In my table example, I have a row with id = 914.
When I run the following request:
select * from example where id='914z';
MySQL returns the row with id = 914.
Why???
I mean... '914' is NOT '914z' !
I believe that this is completely not normal.
If you don't, please tell me why, I'd be happy to discuss.
It works exactly as it should, and the behaviour is documented. Documentation has good examples:
The following examples illustrate conversion of strings to numbers
for comparison operations:
mysql> SELECT 1 > '6x'; -> 0
mysql> SELECT 7 > '6x'; -> 1
mysql> SELECT 0 > 'x6'; -> 0
mysql> SELECT 0 = 'x6'; -> 1

How does this Update Statement work?

I had a coworker today write a improperly written SQL update.
UPDATE table SET column = 'change'
WHERE id = 2401 OR 2402 OR 2403 OR 2404 OR 2405 OR 2406;
Query OK, 264 rows affected (0.03 sec)
Rows matched: 9997 Changed: 264 Warnings: 0
Why would this work?
I thought at most it would update 1 row with ID being unique. and 2402 and 2403....etc not being matched against anything.
What happened is OR 2402 was treated as a true value, as if you put 1 = 1 or another condition that always returns true. Your query was read by MySQL as
UPDATE table SET column = 'change'
WHERE id = 2401 OR true OR true OR true OR true OR true;
That statement is wrong and would update all your records. The
correct query is:
UPDATE table
SET column = 'change'
WHERE id = 2401 OR id= 2402 OR id=2403 OR id=2404 OR id=2405 OR id=2406;
or better:
UPDATE table
SET column = 'change'
WHERE id IN (2401,2402,2403,2404,2405,2406);
your original query updates record whose id is 2401 and any other row for which holds that 2042 is "true" which it is for all (as 2042 isn't 0 or false)

Can't update table in MySQL, I am using the workbench

I am a fairly new user to MySQL although I am fairly experienced with SQL (DB2 environment). I am using the workbench to run queries and update statements. I am having a problem updating data in a table which I have been able to prior. I'm able to select rows but when I go to update based on the same criteria, the return message is:
**0 row(s) affected Rows matched: 9 Changed: 0 Warnings: 0**
Update gina1.proj001_bcbs set contract_percentage = 1.50
where contract_category = 'All Other Services'
and doctor = 'JSmith' ;
When I run the same WHERE clause with a select I get the correct list of records.
**9 row(s) returned** and I get the correct list of data.
select * from gina1.proj001_bcbs
where contract_category = 'All Other Services'
and doctor = 'JSmith' ;
I do not believe I am logging but I can't say for sure, I did ready somewhere about resetting the log. If someone can help it would be great.
This means simply, that all relevant records already have contract_percentage = 1.50
0 row(s) affected : No rows were affected by your query
Rows matched: 9 : 9 rows were found, ...
Changed: 0 : ... but none of them had to be changed
Warnings: 0 : Nothing recoverable bad happened while runinng the query
.
Update gina1.proj001_bcbs set contract_percentage = 2.50
where contract_category = 'All Other Services' and doctor = 'JSmith' ;
Is ver likely to bring you 9 row(s) affected Rows matched: 9 Changed: 9 Warnings: 0