且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

删除字符串后的所有内容

更新时间:2023-02-21 20:09:46

SELECT 
trim( -- trim removes spaces before and after given string
    left(
        'some text < iframe', 
        locate('< iframe', 'some text < iframe') - 1
    )
);

为了更好地理解,我没有删除 iframe 之间的空格.

For better understanding i did not removed space between < and iframe.

你也可以看看这个帖子:

You may also take a look at this thread:

从记录中删除 HTML 标签

但这是关于仅删除标签并在标签之间保留 text 的讨论.无论如何它会适合你,因为你在 之间没有任何东西.

but this is discussion about removing tags only, and keeping <tag>text</tag> between tags. Anyway it will for for you, because you have nothing between <iframe> and </iframe>.