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. 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 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 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? 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. 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? 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); Link to comment https://forums.phpfreaks.com/topic/221803-deleting-stuff/#findComment-1147879 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.