Created
April 27, 2018 13:21
-
-
Save shadyvb/bbedbc6917ccbbca35c908fe50a11010 to your computer and use it in GitHub Desktop.
SQL Query to remove uncategorised category from categorised articles
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
DELETE | |
FROM `{PREFIX}_term_relationships` | |
WHERE `term_taxonomy_id` = 1 AND `object_id` IN | |
( SELECT * FROM | |
( | |
SELECT object_id | |
FROM `{PREFIX}_term_relationships` | |
WHERE `term_taxonomy_id` | |
IN ( SELECT `term_taxonomy_id` | |
FROM `{PREFIX}_term_taxonomy` | |
WHERE `taxonomy` = 'category' ) | |
GROUP BY `object_id` | |
HAVING ( COUNT( `object_id` ) > 1 ) | |
) | |
AS X | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment