简体   繁体   English

SQL查询以删除以特定文本开头和结尾的单元格中的文本

[英]SQL Query to Delete Text Within a Cell That Begins and Ends with Specific Text

I need to delete data from a column that begins and ends with specific text. 我需要从以特定文本开头和结尾的列中删除数据。

I have 800 records, the data between the text I want to remove is different in all the 800 records. 我有800条记录,我要删除的文本之间的数据在所有800条记录中都不同。

For example: 例如:
This house is big /br/br link img src house.png /br 这个房子很大/ br / br链接img src house.png / br

I want to delete everything between the /br/br and the /br. 我想删除/ br / br和/ br之间的所有内容。

How would I write this query? 我将如何编写此查询?

Try something like this: 尝试这样的事情:

update t
set s = concat (
        substr(s, 1, locate('/br/br', s) + 5),
        substr(s, length(s) - locate('rb/', reverse(s)) - 1)
        )
where s like '%/br/br%br%';

Used locate to find the index of the point to find substrings and then use concat to join the desired parts together. 使用locate查找要查找子字符串的点的索引,然后使用concat将所需的部分连接在一起。

It deletes everything between first /br/br and last /br 它删除第一个/br/br和最后一个/br之间的所有内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM