skip to Main Content

How can I remove or replace a string from a column?
eg: I want from my articles to remove the string:

<p>John say's "Hello Mary"</p>

I try with the REPLACE() function in phpmyadmin but I get an error.
The query is the below:

select `column_name` REPLACE('<p>John say's "Hello Mary"</p>', '<p>John say's "Hello Mary"</p>', '') where id=1234;

Thank you

2

Answers


  1. The syntax for REPLACE() is like this:

    SELECT REPLACE(column_name ,'something','somewhat') FROM your_table WHERE id = 1234;
    

    Also pay attention to quotes: ‘John say’s "Hello Mary"’ – you must escape the one from

    say’s

    for example

    Login or Signup to reply.
  2. The REPLACE() function is often used to correct data in a table, replacing the old string with the new one.

    The following is the syntax:

    UPDATE 
        table_name
    SET
        column_name = REPLACE(column_name, '<p>John say's "Hello Mary"</p>','')
    WHERE
        id=1234;
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search