justinbriggs1 Posted February 10, 2011 Share Posted February 10, 2011 Hey everyone, I am trying to delete across 3 tables without affecting the reliability of the data, but am having a tough time figuring out how. I'm sure there is a standard way of doing this with SQL or the application code (PHP in my case). Here is a short description of my tables:Candidate_table - id_candidate - namePosition_table - id_position - titleRelationship_table - id_position - id_candidate I want to delete the position, and all of the candidates associated with that position. Deleting the Position rows and the Relationship rows are easy:DELETE FROM Position_table WHERE id_position = $id_positionDELETE FROM Relationship_table WHERE id_position = $id_positionBut what is the easiest way to delete the correct candidate from the Candidate_table with only the id_position? For instance, I don't want to delete the candidate if they are assigned to more than one position. Having a hard time wrapping my head around it. Any help would be appreciated. Link to comment Share on other sites More sharing options...
[dx] Posted February 10, 2011 Share Posted February 10, 2011 You should have separated ID for every position.So there can be:id name1 jwburnside2 jwburnsideSo when you delete id 1, id 2 is still there. Link to comment Share on other sites More sharing options...
justinbriggs1 Posted February 10, 2011 Author Share Posted February 10, 2011 I'm not sure I understand, which table are you referring to in your answer? Also, it seems like if your solution would produce redundant data, which is what I was trying to avoid. Could you elaborate? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.