1 DROP TABLE IF EXISTS item_test;
3 SELECT 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)
10 GROUP BY u.`item_guid`
14 DELETE FROM auctionhouse WHERE itemguid IN (SELECT item_guid FROM item_test WHERE `source`='i');
15 DELETE FROM mail_items WHERE item_guid IN (SELECT item_guid FROM item_test WHERE `source`='i');
16 DELETE FROM guild_bank_item WHERE item_guid IN (SELECT item_guid FROM item_test WHERE `source`='i');
18 DELETE FROM mail_items WHERE item_guid IN (SELECT item_guid FROM item_test WHERE `source`='a');
19 DELETE FROM guild_bank_item WHERE item_guid IN (SELECT item_guid FROM item_test WHERE `source`='a');
21 DELETE FROM guild_bank_item WHERE item_guid IN (SELECT item_guid FROM item_test WHERE `source`='m');
22 DROP TABLE IF EXISTS item_test;