Skip to content Skip to sidebar Skip to footer

Using Update And Replace With Wildcards

UPDATE database_posts SET post_content = REPLACE (post_content,'%submitted by%%%%%', ''); Is it possible in SQL to perform an UPDATE and REPLACE using wildcards? I'm trying t

Solution 1:

If you want to keep everything up to submitted by and nothing after, you can use substring_index():

UPDATE database_posts 
    SET post_content = SUBSTRING_INDEX(post_content, 'submitted     by', 1)
    WHERE post_content LIKE'%submitted     by%';

I have no idea what all the spaces are between "submitted" and "by", but they are in your question.

Post a Comment for "Using Update And Replace With Wildcards"