SQL: search/replace but only the first time a value appears in record

后端 未结 9 821
执念已碎
执念已碎 2020-12-11 02:11

I have html content in the post_content column.

I want to search and replace A with B but only the first time A appears in the record as it may appear more than onc

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-11 02:52

    It's simpler

    UPDATE table_name SET column_name = CONCAT('A',SUBSTRING(column_name, INSTR(column_name, 'B') + LENGTH('A')));
    

提交回复
热议问题