aprillougheed Posted June 6, 2003 Share Posted June 6, 2003 I\'m sure this question has been asked before, but I couldn\'t find the answer. I\'m running an online form for an irrigation company. We have a form that uses PHP to write to MySql. I\'d like to have an auto-incremented unique \"row\" id and I\'d like to have an auto-incremented unique \"customer\" id. When a new customer registers, their information is posted to two different tables. I\'d like the unique Customer ID to post to both tables. If I understand how this works . . . I should then be able to query Table A and Table B for Customer ID XXX - and the script will pull some data from Table A and some data from Table B for Customer ID XXX. Does this make sense? So I\'m not sure if PHP should/can assign a unique CustomerID or if it will be MySQL ??? I\'ve got six books on PHP/MySQL and I can\'t find one that tells me how to do this -- can you believe it? Hey, this is a cool forum. Glad I found you guys. PHP is addicting isn\'t it? Quote Link to comment https://forums.phpfreaks.com/topic/554-need-two-unique-identifiers/ Share on other sites More sharing options...
shivabharat Posted June 7, 2003 Share Posted June 7, 2003 Learn more about Foreign key A small definition A foreign key, also called a foreign keyword, in a database table is a key from another table that refers to (or targets) a specific key, usually the primary key , in the table being used. A primary key can be targeted by multiple foreign keys from other tables. But a primary key does not necessarily have to be the target of any foreign keys. It is possible to change the primary key in a table when the specific needs of the users change. For example, the people in a town might be uniquely identified according to their driver license numbers in one application, but in another situation it might be more convenient to identify them according to their telephone numbers. When the primary key in a table is changed, the set of associated foreign keys, if there are any, often changes as a result. Quote Link to comment https://forums.phpfreaks.com/topic/554-need-two-unique-identifiers/#findComment-1865 Share on other sites More sharing options...
aprillougheed Posted June 7, 2003 Author Share Posted June 7, 2003 Thank you for the lead. Did you find that at php.net or MySql.com? Elsewhere? I\'m always irritated by people who ask questions before they check the manual themselves. I did check the manual(s), but I didn\'t search for \"foreign key\" - so I\'ll go back and look again. Appreciate your help. April Quote Link to comment https://forums.phpfreaks.com/topic/554-need-two-unique-identifiers/#findComment-1867 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.