leeh14 Posted October 19, 2010 Share Posted October 19, 2010 Hi, Just need to know if I am on the right lines, basically I am about to create two tables; one to hold customer information and another to hold information the customer gave me. Both tables will be populated with information that they give me at the same time (in other words from a single form). Just want to know, if I have a field called ID set to a primary key in both the tables, will that be enough to link them both together? Furthermore, what would the mySQL code look like if I wanted to view all the information referencing to specific ID? so info from the customer table and the other. Any and all help would be great. Lee Quote Link to comment Share on other sites More sharing options...
turkman Posted October 19, 2010 Share Posted October 19, 2010 No, they would only be joined when you execute a sql join comman. SELECT * FROM tbl_a LEFT JOIN tbl_b ON tbl_a.id = tbl_b.id Quote Link to comment Share on other sites More sharing options...
leeh14 Posted October 19, 2010 Author Share Posted October 19, 2010 So would that line of code need to be run every time i wanted to retrive or add some data? Quote Link to comment Share on other sites More sharing options...
leeh14 Posted October 19, 2010 Author Share Posted October 19, 2010 Sorry I was being a fool, i understand that statement now. But it does lead me to anouther question; when adding information for the first time information will go into both tables at the same time, but how will i make sure that the ID number is the same inside both the tables? Quote Link to comment Share on other sites More sharing options...
Miss_Rebelx Posted October 19, 2010 Share Posted October 19, 2010 Do you have the field set to auto increment, or some other sequence/trigger, or are you manually setting the value? Quote Link to comment Share on other sites More sharing options...
leeh14 Posted October 19, 2010 Author Share Posted October 19, 2010 Hi, well i have not made the tables yet, but was going to have them on 'auto_increment' is there a better way to do it though?? Quote Link to comment Share on other sites More sharing options...
leeh14 Posted October 19, 2010 Author Share Posted October 19, 2010 So, do people believe that auto increment is the best way to go about making theses tables? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 yes. Quote Link to comment 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.