Search code examples
mysqlalter

How to change specific part of the text in MySQL for selected column?


I have a table news, it has a column description. In the descriptions' column I use <p> tags. I want all the <p> tags to be changed into <p itemprop="description"> . How can I do it?


Solution

  • Try this;

    UPDATE `news`
    SET `description` = REPLACE(description, '<p>', '<p itemprop="description">')
    

    https://dev.mysql.com/doc/refman/5.7/en/string-functions.html