root/trunk/sql/tools/characters_item_duplicates_remove.sql

Revision 2, 1.2 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1DROP TABLE IF EXISTS item_test;
2CREATE TABLE item_test
3SELECT w.`item_guid`,w.`source`,w.`count` FROM
4  (SELECT u.`item_guid`,u.`source`,COUNT(u.`item_guid`) as `count` FROM
5    ((SELECT c.`item`      as `item_guid`, 'i' as `source` FROM character_inventory c) UNION
6     (SELECT a.`itemguid`  as `item_guid`, 'a' as `source` FROM auctionhouse        a) UNION
7     (SELECT m.`item_guid` as `item_guid`, 'm' as `source` FROM mail_items          m) UNION
8     (SELECT g.`item_guid` as `item_guid`, 'g' as `source` FROM guild_bank_item     g)
9    ) as u
10   GROUP BY u.`item_guid`
11  ) as w
12 WHERE w.`count` > 1;
13
14DELETE FROM auctionhouse    WHERE itemguid  IN (SELECT item_guid FROM item_test WHERE `source`='i');
15DELETE FROM mail_items      WHERE item_guid IN (SELECT item_guid FROM item_test WHERE `source`='i');
16DELETE FROM guild_bank_item WHERE item_guid IN (SELECT item_guid FROM item_test WHERE `source`='i');
17
18DELETE FROM mail_items      WHERE item_guid IN (SELECT item_guid FROM item_test WHERE `source`='a');
19DELETE FROM guild_bank_item WHERE item_guid IN (SELECT item_guid FROM item_test WHERE `source`='a');
20
21DELETE FROM guild_bank_item WHERE item_guid IN (SELECT item_guid FROM item_test WHERE `source`='m');
22DROP TABLE IF EXISTS item_test;
Note: See TracBrowser for help on using the browser.