Home > database >  Mysql to replace before the suffix
Mysql to replace before the suffix

Time:10-23

Now have a lot in my code & lt; Img> The label, I want to & lt; Img> Respectively before and after the label plus & lt; P> And & lt;/p> Label, could you tell me how to write a SQL statement?

CodePudding user response:

The update table name set column name=REPLACE (column name, '& lt; Img> ', '& lt; P>

') where column like '% & lt; Img> % ';
Or do not add condition
The update table name set column name=REPLACE (column name, '& lt; Img> ', '& lt; P>

');

CodePudding user response:

reference 1/f, healthy monkeys response:
update table name set column name=REPLACE (column name, '& lt; Img> ', '& lt; P>

') where column like '% & lt; Img> % ';
Or do not add condition
The update table name set column name=REPLACE (column name, '& lt; Img> ', '& lt; P>

');


Each image path is different, such as & lt; Img SRC="https://bbs.csdn.net//profile.csdnimg.cn/F/C/8/1_sihailiuyun" & gt; Such, could you tell me how to use the wildcard replacement?

CodePudding user response:

The update table name set column name=REPLACE (column name, '& lt; Img> ', '& lt; P>

') where column like '% & lt; Img % & gt; % ';
Use % in the img tag, inside the path not to have & gt; Symbol should be ok

CodePudding user response:

Mass changes, this is not recommended to change the database directly, the back-end code, write a unified processing method,
  • Related