Jump to content


Need two Unique Identifiers

  • Please log in to reply
2 replies to this topic

#1 aprillougheed

  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 06 June 2003 - 11:26 PM

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?
April L Lougheed

#2 shivabharat

  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 07 June 2003 - 05:46 AM

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.

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks

#3 aprillougheed

  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 07 June 2003 - 04:38 PM

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 L Lougheed

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users