diff options
Diffstat (limited to 'remove-badges-variants.mysql')
-rw-r--r-- | remove-badges-variants.mysql | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/remove-badges-variants.mysql b/remove-badges-variants.mysql new file mode 100644 index 0000000..8108fad --- /dev/null +++ b/remove-badges-variants.mysql @@ -0,0 +1,16 @@ + +USE lastfm + + +/** + * Deletes all entries in badges + * for each unique username + type + * where more than one style or color exists + */ + +DROP TABLE IF EXISTS tmp ; +CREATE TEMPORARY TABLE tmp (SELECT username, type, COUNT(username) AS count FROM badges GROUP BY username, type ) ; +SELECT badges.username, badges.type, badges.style, badges.color FROM badges, tmp WHERE badges.username = tmp.username AND badges.type = tmp.type AND tmp.count > 1 ; +DELETE badges FROM badges, tmp WHERE badges.username = tmp.username AND badges.type = tmp.type AND tmp.count > 1 ; +DROP TABLE tmp ; + |