August 10, 200917 yr Right, am branching out into MySQL here for the very first time and stuck for a solution. I'm sure this is really simple, but have yet to find a consistent answer on the net and don't want to balls it up! Basically I'm looking to delete any items in the table "order" where the "user_id" does not exist in table "users". So in other words if the user is no longer with us strip out any historical orders they've placed. Any ideas?
August 10, 200917 yr okay its not easy but your going to need to join the tables with mysql, then do a search of the tables
August 13, 200917 yr Right, am branching out into MySQL here for the very first time and stuck for a solution. I'm sure this is really simple, but have yet to find a consistent answer on the net and don't want to balls it up! Basically I'm looking to delete any items in the table "order" where the "user_id" does not exist in table "users". So in other words if the user is no longer with us strip out any historical orders they've placed. Any ideas? DELETE FROM Orders o WHERE o.User_ID NOT IN (SELECT DISTINCT(User_ID) FROM Users) ...should do the trick.
August 16, 200917 yr You just have to make sure you have covered every eventuality. Then once you have done this you need to test the hell out of it!
Create an account or sign in to comment