Maracles Posted November 2, 2009 Share Posted November 2, 2009 I have just read a large number of tutorials and advice online as well as a book I have here and I don't really understand joins/linking tables. I have created a table called 'title' which has two fields titleID - this is the primary key and is an auto-incrementing integer title - this is the films actual title I want to create a table called 'boxoffice' which links a particular film title, via titleID, to its boxoffice results. What I cannot understand is how to take the titleID column I have in the 'title' table and place it in the 'boxoffice' table. Do I simply create a new field in 'boxoffice' called 'titleID' with the same strucutre and then somehow link this with the original 'titleID'? I have tried using the relationship view in phpMyAdmin however when I link to the title.titleID field it does not end up displaying in the boxoffice table. What am I doing wrong? It is important to note that I am NOT trying to output a result that shows a combination of a table, I am actually trying to link the titleID into the boxoffice table so that they are stored together in my database. I know this is a bit of a mess of a an explanation but if someone can help me directly or link me to a decent tutorial that explains all this it would be much appreciated. I am using PHPmyadmin to try and do this however answers in MySQL are also appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/180028-can-someone-help-me-understand-joins/ Share on other sites More sharing options...
kickstart Posted November 3, 2009 Share Posted November 3, 2009 Hi They are seperate tables. You would have one table with your titleId and title in it, and the box office table would contain the titleId for that particular film. You would have to insert the matching titleId into the box office table. Normally using MySQL you would insert something into the title table and use mysql_insert_id to get the generated titleId, and then you would use that when inserting to the box office table The JOIN would come when you wanted to extract the data and you would link the 2 tables on the titleId. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/180028-can-someone-help-me-understand-joins/#findComment-949805 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.