MYSQL: add posts to an array of categories based on REGEX. only seem to be able add one category instead of array
Question
I want to add posts to category called “New York” (ID 88) and also to category “USA” (ID 89) based on regex,
I cannot seem to get it to add to both at once. Managed to get it working just for one.
REPLACE INTO wp_term_relationships (term_taxonomy_id, object_id) SELECT '88', ID
FROM `wp_posts`
WHERE (post_title REGEXP 'New York|N.Y.|bnyb|NYC|NewYork|Bronx|Brooklyn|Staten Island|Big Apple|Manhattan|Queens|Newark.?.?.?NJ'
OR post_content REGEXP 'New York|N.Y.|bnyb|NYC|NewYork|Bronx|Brooklyn|Staten Island|Big Apple|Manhattan|Queens|Newark.?.?.?NJ'
OR post_title COLLATE utf8mb4_bin REGEXP 'bNYb'
OR post_content COLLATE utf8mb4_bin REGEXP 'bNYb'
)
AND (post_type = 'post' OR post_type = 'xdays1')
I tried:
REPLACE INTO wp_term_relationships (term_taxonomy_id, object_id) SELECT '88,89', ID
FROM `wp_posts`
and
REPLACE INTO wp_term_relationships (term_taxonomy_id, object_id) SELECT '88' AND SELECT '89', ID
FROM `wp_posts`
help appreciated!
0
array, categories, mysql, posts, regex
3 years
2020-05-30T01:10:23-05:00
2020-05-30T01:10:23-05:00 0 Answers
93 views
0
Leave an answer