[英]Using replace and concat in MySQL 8 version
我在一列中有如下字符串值:
<span style=text-align: justify;>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</span>
我想執行如下平衡字符串替換:
<p style=margin-top: 0;>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p>
我嘗試使用 REPLACE 和 CONCAT 函數來執行此操作,但沒有得到所需的 output。
例如:
mysql> SELECT REPLACE (
contents,
CONCAT( "<span style=text-align: justify;>", contents, "</span>" ),
CONCAT( "<p style=margin-top: 0;>", contents, "</p>" )) q
FROM
t_contents
WHERE
contents LIKE '%<span style=text-align: justify;>%';
+--------------------------------------------------------------------------------------------------------------------+
| q |
+--------------------------------------------------------------------------------------------------------------------+
| <span style=text-align: justify;>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</span> |
+--------------------------------------------------------------------------------------------------------------------+
1 row in set (0.14 sec)
如何在 MySQL 8 版本中實現此結果?
嘗試這樣的事情:
SELECT REPLACE( REPLACE(
'<span style=text-align: justify;>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</span>','<span style=text-align: justify;>','<p style=margin-top: 0;>'),
'</span>','</p>')
;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.