Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    SQL Query for Find and Replace is not working


    Hello,

    i want to run a find and replace query in my sql database using php my admin. The problem is that in the text that i want to find and replace are some " characters and this causes problems when i run the command...

    i want to search for align="right"> and replace it by align="left">

    i did run this command but its not working:

    UPDATE `ps_product_lang` SET `description` = replace(`description`,"align="right">","align="lef t">");

    So im wondering how should this query look like as there are " characters? How is it possible to search for even much longer text and replace it using sql queries?

    many thanks

  2. #2
    Linux Enthusiast
    Join Date
    Apr 2004
    Location
    UK
    Posts
    747
    Hi there,

    You need to escape the quote marks you that are part of the text you are searching for. So something like: "align=\"right\">".

    I'm not sure what you mean how searching for longer text. As long as the MySql doesn't choke on the string you should be fine.

    Let us know how you get on.
    To be good, you must first be bad. "Newbie" is a rank, not a slight.

  3. #3
    Quote Originally Posted by kakariko81280 View Post
    Hi there,

    You need to escape the quote marks you that are part of the text you are searching for. So something like: "align=\"right\">".

    I'm not sure what you mean how searching for longer text. As long as the MySql doesn't choke on the string you should be fine.

    Let us know how you get on.
    Thank you very much but like that it was not working

    I got it working now with this query:

    UPDATE `ps_product_lang` SET `description` = replace(`description`, 'align="right">', 'align="left">');

  4. $spacer_open
    $spacer_close
  5. #4
    Glad you got it sorted, and thanks for posting your solution.

    Marking thread as Solved.

Posting Permissions

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