blob: 1d3d918da69cdf5f3187adfd7b5d4a10cf631a60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
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 * FROM tmp WHERE count > 1 ;
DELETE badges FROM badges, tmp WHERE badges.username = tmp.username AND tmp.count > 1 ;
DROP TABLE tmp ;
|