Created
October 23, 2023 14:34
-
-
Save bschulz87/74315bc555b502250200ee79a0ad3a7b to your computer and use it in GitHub Desktop.
Simple case insensitive search replace wordpress meta values
This file contains hidden or 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
SET @old = "Holzbraun"; | |
SET @new = "wooden"; | |
SET @meta_key = "color"; | |
UPDATE wp_postmeta | |
SET meta_value = REPLACE(REPLACE(meta_value,@old,@new),LOWER(@old),@new) | |
WHERE LOWER(meta_value) LIKE LOWER(CONCAT('%',@old,'%')) AND meta_key = @meta_key; | |
SELECT meta_id, post_id, meta_key, meta_value | |
FROM wp_postmeta | |
WHERE LOWER(meta_value) LIKE LOWER(CONCAT('%',@old,'%')) AND meta_key = @meta_key; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment