Go Back   EQEmulator Home > EQEmulator Forums > Archives > Archive::Development > Archive::Database/World Building

Archive::Database/World Building Archive area for General Discussion's posts that were moved here after an inactivity period of 90 days.

Reply
 
Thread Tools Display Modes
  #1  
Old 01-25-2004, 08:13 PM
masticism
Fire Beetle
 
Join Date: Aug 2003
Posts: 9
Default Further DB Cleaning of Duplicates

I did this mainly to get rid of the duplicate NPC's in paineel (they were starting to annoy me). They may be there for a reason but until the "proper" update gets finished, this will at least get rid of them. No gaurantees though. There is most likely intentional duplicates that are being removed as well...


Adapted from molly's SQL:

1) First, verify that there are duplicates that we want removed:

Code:
SELECT 
  `spawn2`.`x`,
  `spawn2`.`y`,
  `spawn2`.`z`,
  `spawn2`.`zone`,
  `npc_types`.`name`,
  count(`spawn2`.`id`) AS `SpawnCount`
FROM
  `npc_types`
  INNER JOIN `spawnentry` ON (`npc_types`.`id` = `spawnentry`.`npcID`)
  INNER JOIN `spawn2` ON (`spawnentry`.`spawngroupID` = `spawn2`.`spawngroupID`)
WHERE
   spawn2.pathgrid = 0
GROUP BY
  `spawn2`.`x`,
  `spawn2`.`y`,
  `spawn2`.`z`,
  `spawn2`.`zone`
HAVING
  (`SpawnCount` = 2)
ORDER BY
  `spawn2`.`zone`,
  `spawn2`.`x`,
  `spawn2`.`y`,
  `spawn2`.`z`
2) Next, for the deletion, we just reuse pieces from above:

Code:
SELECT CONCAT('delete from spawn2 WHERE id = ', max(spawn2.id),';DELETE FROM spawnentry WHERE spawngroupID = ', max(spawn2.spawngroupID),';') Query
FROM
  `npc_types`
  INNER JOIN `spawnentry` ON (`npc_types`.`id` = `spawnentry`.`npcID`)
  INNER JOIN `spawn2` ON (`spawnentry`.`spawngroupID` = `spawn2`.`spawngroupID`)
WHERE
   spawn2.pathgrid = 0
GROUP BY
  `spawn2`.`x`,
  `spawn2`.`y`,
  `spawn2`.`z`,
  `spawn2`.`zone`
HAVING
  COUNT(spawn2.id) =2
ORDER BY
  `spawn2`.`zone`,
  `spawn2`.`x`,
  `spawn2`.`y`,
  `spawn2`.`z`
3) This will give several SQL statements that will delete the highest ID of the duplicate entry.

Again no gaurantees on this, use at your own risk etc.

Thanks to molly for the great inspiration for this!!!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 05:05 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3