简体   繁体   English

SQL替换值通配符

[英]SQL replace value wildcard

I've tried searching stackoverflow for an answer but couldn't find any (M*ight be my mistake by not understanding?)*. 我试图在stackoverflow上寻找答案,但找不到任何答案(M *可能是我不理解而犯的错误?)*。

Anyway, I'm looking for a SQL Query that replaces X with Y . 无论如何,我正在寻找一个将Y替换为X的SQL查询。 (I'm using MySQL as DMBS) (我正在使用MySQL作为DMBS)

The problem is that X is not static . 问题是X不是静态的 X variates from [hello=world], [hello=planet], [hello=goodbye] . X从[hello=world], [hello=planet], [hello=goodbye]

Is there anyway I can wildcard the parts after =? 无论如何,我可以在=之后使用通配符吗?

The reason why I'm asking this is because I want to mass replace it. 我之所以这样问,是因为我想大量替换它。

UPDATE messages set hello = replace(hello,'?','[replacement]')

Thank you! 谢谢!

update messages set hello = [replacement] where hello like '[hello%'

% is used for wildcard comparison in text. %用于文本中的通配符比较。 if you are sure that all of your fields start with "[hello". 如果您确定所有字段都以“ [hello”开头。 then "[hello% will work in your case. if "hello" is in the middle the text and you are not sure about the start of the text. then you can use "%hello%". 那么“ [hello%将在您的情况下起作用。如果” hello”在文本的中间,并且您不确定文本的开头。则可以使用”%hello%”。

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

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