I have a table that contains html links similar to this one:
我有一个表包含类似于这一个的HTML链接:
<a href=" http://link.com"><img src="images.png"/></a>
I would like to insert target="_blank" into these links, like so:
我想在这些链接中插入target =“_ blank”,如下所示:
<a href=" http://link.com" target="_blank"><img src="images.png"/></a>
Does anyone know how to write the query to insert (target="_blank") into each table column at the right position within the html link?
有谁知道如何编写查询以插入(target =“_ blank”)到html链接中正确位置的每个表列?
Thanks to those who answered.
感谢那些回答的人。
2 个解决方案
#1
0
Replace()
should work for this case:
Replace()适用于这种情况:
update table t
set link = replace(link, 'link.com"', 'link.com" target="_blank"');
#2
0
I think this should work, but it depends on that the <img
attribute follows the link. It does not rely on any specific link text.
我认为这应该有效,但这取决于 属性是否在链接之后。它不依赖于任何特定的链接文本。
update your_table set your_text = replace(your_text, '><img', ' target="_blank"><img')
示例SQL小提琴
#1
0
Replace()
should work for this case:
Replace()适用于这种情况:
update table t
set link = replace(link, 'link.com"', 'link.com" target="_blank"');
#2
0
I think this should work, but it depends on that the <img
attribute follows the link. It does not rely on any specific link text.
我认为这应该有效,但这取决于 属性是否在链接之后。它不依赖于任何特定的链接文本。
update your_table set your_text = replace(your_text, '><img', ' target="_blank"><img')
示例SQL小提琴