简体   繁体   中英

Replace substring with wildcard in MySQL

I'm trying to write an SQL update to replace a specific CSS property with a blank so I can remove it.

Let's see:

UPDATE table
SET css_string = REPLACE(css_string, "top:calc(50%%ANY_VALUE%%) !important;", " ");

So that I can remove the top:calc(50% - 20px) !important; property from the CSS string.

I'll take a stab at it, been a while since I have worked with SQL:

UPDATE table
SET css_string = REPLACE(css_string,"top:calc(50%) !important;"," ");

Before you go updating you can run some queries like:

Select css_string, REPLACE(css_string,"top:calc(50%) !important;"," ") as "change to" from table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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