Guest Anonymous Posted September 26, 2007 Share Posted September 26, 2007 How do I write a query to compare the users database to the inventory, userstats, mail, and forum topics and replies tables and delete all data from userids that have been deleted from the users database? someone help me I have about 2000 IDs that I deleted from my game for inactivity.. but their info remains in the fed the userstats inventory just to name a few. Quote Link to comment Share on other sites More sharing options...
UCC Posted September 26, 2007 Share Posted September 26, 2007 Re: How do I delete orphaned data I do something like delete from userstats where userid not in (select userid from users) I dont claim it to be the most efficient query, but it works. Quote Link to comment Share on other sites More sharing options...
hamster01 Posted September 26, 2007 Share Posted September 26, 2007 Re: How do I delete orphaned data How about a delete command? Something like: DELETE FROM inventory,forums,mail,events,users,userstatus WHERE userid='$id' This is simple stuff, I really don't know why people do not bother to go to a place like w3schools and learn something or two. Quote Link to comment Share on other sites More sharing options...
dlion98 Posted September 26, 2007 Share Posted September 26, 2007 Re: How do I delete orphaned data ferdi what do I do if the users table does not have the userid any longer. That is the question. Quote Link to comment Share on other sites More sharing options...
hamster01 Posted September 26, 2007 Share Posted September 26, 2007 Re: How do I delete orphaned data ferdi what do I do if the users table does not have the userid any longer. That is the question. Well, you could actually make a script that handles this, but to make it a simple query, remove the users table from the query. Example: DELETE FROM inventory,forums,mail,events,,userstatus WHERE userid='$id' Quote Link to comment Share on other sites More sharing options...
UCC Posted September 26, 2007 Share Posted September 26, 2007 Re: How do I delete orphaned data Or you could do exactly what I said, *Gasp* Quote Link to comment Share on other sites More sharing options...
dlion98 Posted September 26, 2007 Share Posted September 26, 2007 Re: How do I delete orphaned data Thanks UCC I will try yours as well it looks like from here that it will do what I want it to do. I will let ya know if I have any probs with it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.