Danny620 Posted December 15, 2010 Share Posted December 15, 2010 Hi, Sorry to bother you all like this but I really good do with some help. My problem is I have 3 tables users, case_ref & updates all realated to each other by a user_id - I want to be able to delete from all tables if the users account is deleted. So if a user is deleted so is all the associated data too. delete from users, case_ref, updates where user_id = 1 I would be extremely great full if you could help me out on this one. Quote Link to comment https://forums.phpfreaks.com/topic/221803-deleting-stuff/ Share on other sites More sharing options...
Maq Posted December 15, 2010 Share Posted December 15, 2010 Have a look in the manual, Multiple-table syntax: http://dev.mysql.com/doc/refman/5.0/en/delete.html Quote Link to comment https://forums.phpfreaks.com/topic/221803-deleting-stuff/#findComment-1147854 Share on other sites More sharing options...
Danny620 Posted December 15, 2010 Author Share Posted December 15, 2010 sorry can u help me Quote Link to comment https://forums.phpfreaks.com/topic/221803-deleting-stuff/#findComment-1147857 Share on other sites More sharing options...
Maq Posted December 15, 2010 Share Posted December 15, 2010 What are you having trouble with specifically? Quote Link to comment https://forums.phpfreaks.com/topic/221803-deleting-stuff/#findComment-1147860 Share on other sites More sharing options...
Danny620 Posted December 15, 2010 Author Share Posted December 15, 2010 I just want a query that allows me to delete all records when the user is deleted like DELETE FROM users, case_ref, updates WHERE user_id='9' however this does'tn seem to work in php. Please help me. Quote Link to comment https://forums.phpfreaks.com/topic/221803-deleting-stuff/#findComment-1147862 Share on other sites More sharing options...
Maq Posted December 15, 2010 Share Posted December 15, 2010 Did you look at the link I sent you? It shows you exactly how to do it. Does your query throw and error? What happens? Can you post the current query you have? Quote Link to comment https://forums.phpfreaks.com/topic/221803-deleting-stuff/#findComment-1147873 Share on other sites More sharing options...
Danny620 Posted December 15, 2010 Author Share Posted December 15, 2010 ive add to do 3 // Make the query: $q = "DELETE FROM case_ref WHERE user_id='$id'"; $r = $r = mysqli_query ($dbc, $q); // Make the query: $q = "DELETE FROM case_ref WHERE user_id='$id'"; $r = $r = mysqli_query ($dbc, $q); // Make the query: $q = "DELETE FROM users WHERE user_id='$id'"; $r = $r = mysqli_query ($dbc, $q); Quote Link to comment https://forums.phpfreaks.com/topic/221803-deleting-stuff/#findComment-1147879 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.