蓝海航行家
发布于

MYSQL Update Query 删除部分 Sting

尝试删除字符串的一部分,如下所示

  #Crawlers_Album_The_Mess_We_Seem_To_Make #Crawlers<br><br>[center][url=&quot;https://www.databasedreams.co.uk/charts/index.php?action=gallery;sa=view;id=35847&quot;]

#Crawlers_Album_The_Mess_We_Seem_To_Make #Crawlers<br><br>[center][url=&quot;https://www.databasedreams.co.uk/charts/index.php?action=gallery;sa=view;id=35847&quot;][img]https://www.databasedreams.co.uk/charts/gallery/35/medium_1-270224213050-35846450.jpeg[/img][/url]<br>[music_rawards id=-2028986475]Awards[/music_rawards][/center]<br><br>&nbsp; &nbsp;  Released: [color=pink][size=2]16 February 2024[/size][/color]<br>&nbsp; &nbsp;  Cat no: [color=pink][size=2]5827488[/size][/color]<br>&nbsp; &nbsp;  Album Type: [color=pink][size=2]Studio Album[/size][/color]<br><br>[music_rinfo id=-2028986475]Info[/music_rinfo]<br>[music_rstats id=-2028986475]Stats[/music_rstats]

试过了,但搞砸了,清空了场地

  UPDATE `database_messages` 
SET `body`= RIGHT(`body`, INSTR(`body`,'][img]')+1) 
WHERE `id_board` = 128 and INSTR(`body`,'][img]'); 

我希望删除包含的字符串的第一部分,以便帖子看起来应该像这样[img]

  [img]https://www.databasedreams.co.uk/charts/gallery/35/medium_1-270224213050-35846450.jpeg[/img][/url]<br>[music_rawards id=-2028986475]Awards[/music_rawards][/center]<br><br>&nbsp; &nbsp;  Released: [color=pink][size=2]16 February 2024[/size][/color]<br>&nbsp; &nbsp;  Cat no: [color=pink][size=2]5827488[/size][/color]<br>&nbsp; &nbsp;  Album Type: [color=pink][size=2]Studio Album[/size][/color]<br><br>[music_rinfo id=-2028986475]Info[/music_rinfo]<br>[music_rstats id=-2028986475]Stats[/music_rstats]

在我打算运行 replace for 之后,它会删除该部分的[/img][/url][/url]

浏览 (4)
点赞
收藏
1条评论
Klustron小助手
问题是 that 从末尾开始计数,但返回从开头计数的位置。请改用。RIGHT()INSTR()SUBSTR() UPDATE `database_messages` SET `body`= SUBSTR(`body`, INSTR(`body`,&#39;][img]&#39;)+1) WHERE `id_board` = 128 and INSTR(`body`,&#39;][img]&#39;);
点赞
评论