Results 1 to 3 of 3

Hybrid View

  1. #1
    Join Date
    Oct 2007
    Location
    France & Luxembourg
    Posts
    37
    Plugin Contributions
    0

    database error 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".

    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.



    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

  2. #2
    Join Date
    Jan 2004
    Posts
    66,446
    Plugin Contributions
    81

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

    What happens if you run this query first:
    Code:
    SELECT `products_model`, `products_id` FROM `mypa_store`.`products` WHERE `products_model` LIKE '%376005%';
    if you get 0 records with that, then it would explain why you got 0 records with your UPDATE statement ... your WHERE clause is either incorrect or else there truly are no matching records in the database table you specified.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Oct 2007
    Location
    France & Luxembourg
    Posts
    37
    Plugin Contributions
    0

    Have a Drink 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??
    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.

 

 

Similar Threads

  1. MySQL Syntax error stopped my sending
    By josee225 in forum General Questions
    Replies: 1
    Last Post: 24 May 2009, 04:22 AM
  2. MySQL syntax error
    By Waggle Dancer in forum General Questions
    Replies: 13
    Last Post: 13 Feb 2007, 05:06 AM
  3. Mysql syntax error
    By NeoBlack in forum Setting Up Categories, Products, Attributes
    Replies: 6
    Last Post: 6 Dec 2006, 04:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg