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 Link to comment https://forums.phpfreaks.com/topic/216251-database-and-php-help/ 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 Link to comment https://forums.phpfreaks.com/topic/216251-database-and-php-help/#findComment-1123813 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? Link to comment https://forums.phpfreaks.com/topic/216251-database-and-php-help/#findComment-1123816 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? Link to comment https://forums.phpfreaks.com/topic/216251-database-and-php-help/#findComment-1123821 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? Link to comment https://forums.phpfreaks.com/topic/216251-database-and-php-help/#findComment-1123843 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?? Link to comment https://forums.phpfreaks.com/topic/216251-database-and-php-help/#findComment-1123882 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? Link to comment https://forums.phpfreaks.com/topic/216251-database-and-php-help/#findComment-1123950 Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 yes. Link to comment https://forums.phpfreaks.com/topic/216251-database-and-php-help/#findComment-1123952 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.