mysql - Need SQL Query Help: How to Search and Replace Specific Text LIKE x AND NOT LIKE xx -


and in advance help. i'm working on fixing broken links in massive wordpress multisite database , need writing sql query run via php myadmin. i've searched, can't perfect solution...

problem: have more thousand broken links start http:/ instead of http://

challenge: following result in numerous links starting http:///

    update wp_1_posts     set post_content = replace (post_content,      'http:/',      'http://'); 

process: want write query select these links first, can review them ensure don't damage when replacing text string. downloading db dump , doing manual s&r not option since we're talking multi-gigabyte database.

i thought work...

    select * wp_1_posts     post_content '%http:/%'     , post_content not '%http://%' 

but throws syntax error. close?

question #1: how can find instances of "http:/" without returning "http://" instances in query results.

question #2: how might safely fix instances of "http:/" without affecting "http://" strings.

fyi: i'll admit know enough dangerous, , not familiar regular expressions. at. all. that's why i'm turning help. again!

this should work, in mysql:

update wp_1_posts set post_content = replace(post_content,'http:/', 'http://')  post_content regexp 'http:/[^/]' 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -