From c187cb0a45231b91018b318cd6494123fa4e221a Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Mon, 10 May 2010 17:36:26 +0200 Subject: [DataBase] little cleanup --- DataBase/show-variants.mysql | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 DataBase/show-variants.mysql (limited to 'DataBase/show-variants.mysql') diff --git a/DataBase/show-variants.mysql b/DataBase/show-variants.mysql new file mode 100644 index 0000000..3eeeeac --- /dev/null +++ b/DataBase/show-variants.mysql @@ -0,0 +1,23 @@ + +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, badges.hits, tmp.count + FROM badges, tmp + WHERE badges.username = tmp.username + AND ( (badges.type = tmp.type AND tmp.count > 1) + OR ( (badges.type LIKE concat(tmp.type,"%") OR tmp.type LIKE concat(badges.type,"%")) + AND badges.type != tmp.type ) + ) ; + +DROP TABLE tmp ; + -- cgit v1.2.3