Zen Cart Logo
Forums / Upgrading from 1.3.x to 1.3.9 / find/replace (sub)strings in zen's mysql-DB (mysql syntax question)

find/replace (sub)strings in zen's mysql-DB (mysql syntax question)

Locked

Views: 2,787

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
19 Oct 2007, 9:44 AM
#1
mypashop avatar

mypashop

New Zenner

Join Date:
Oct 2007
Location:
France & Luxembourg
Posts:
37
Plugin Contributions:
0

find/replace (sub)strings in zen's mysql-DB (mysql syntax question)

hello, i have an issue with SQL's syntax. I am moving a DB to another server/version.

this is my SQL-query.

UPDATE mypa_store.products SET products_model = REPLACE(products_model,'376005','') WHERE products_model LIKE '%376005%';

I want it to "strip" (using REPLACE) '376005' in every product model
where it occurs in strings like '376005xxxxxx' . Unfortunately i cannot
figure out what to do, the query results in a "success" on "0 rows affected".

:oops:
I tried hard but don't understand how the sql-manual wants me to use it.
the best, error free query i made was the one on top. :dontgetit

while this is more a mysql related-question, it thought it might help
some other people who need to batch-rename product models or other
strings in their zencart DB.

Anyway many thanks for the help

19 Oct 2007, 12:27 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: find/replace (sub)strings in zen's mysql-DB (mysql syntax question)

What happens if you run this query first:```
SELECT products_model, products_id FROM mypa_store.products WHERE products_model LIKE '%376005%';

19 Oct 2007, 1:21 PM
#3
mypashop avatar

mypashop

New Zenner

Join Date:
Oct 2007
Location:
France & Luxembourg
Posts:
37
Plugin Contributions:
0

Re: find/replace (sub)strings in zen's mysql-DB (mysql syntax question)

i was trying too hard to achieve this, and after getting lots of errors and finally putting the code together, it worked, but i did´t notice it. All i saw was the 0 rows affected... At some point it worked to strip the digits, can you confirm the syntax is correct??
:clap: thanx dr byte, i queried the DB like you said and saw there were no more results... and then i saw the stripped strings. great. Many thanx.