Created
October 8, 2014 17:00
-
-
Save thomasplevy/c34ca1252cb2ed79829f to your computer and use it in GitHub Desktop.
MySQL Database Find and Replace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# @source http://stackoverflow.com/a/19374770/400568 | |
### | |
SELECT t, | |
INSERT(col, | |
LOCATE(@start, col), | |
LOCATE(@end, col) + CHAR_LENGTH(@end) - LOCATE(@start, col), | |
'') with_delimiters_replaced, | |
INSERT(col, | |
LOCATE(@start, col) + CHAR_LENGTH(@start), | |
LOCATE(@end, col) - LOCATE(@start, col) - CHAR_LENGTH(@start), | |
'') without_delimiters_replaced | |
FROM wp_posts.col, (SELECT @start := 'CHANGE:START', @end := 'CHANGE:END') init; | |
UPDATE t, (SELECT @start := 'CHANGE:START', @end := 'CHANGE:END') init | |
SET col = INSERT(col, | |
LOCATE(@start, col), | |
LOCATE(@end, col) + CHAR_LENGTH(@end) - LOCATE(@start, col), | |
''); | |
UPDATE wp_posts, (SELECT @start := 'CHANGE:START', @end := 'CHANGE:END') init | |
SET col = INSERT(col, | |
LOCATE(@start, col), | |
LOCATE(@end, col) + CHAR_LENGTH(@end) - LOCATE(@start, col), | |
''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment