Jump to content

Picking Unique ID


PupChow

Recommended Posts

Sorry if this is a very elementary question, but I just cannot seems to find the answer in the books I have (probably because it is very simple?) or online.

What is the best way to create a unique ID? This ID will be used to link up a couple tables, and I was adviced to not use Auto-number field. Is there a easy way to generate a unique number in PHP while it is inserting the data into the database?
Link to comment
https://forums.phpfreaks.com/topic/4992-picking-unique-id/
Share on other sites

Something about it is hard to manage. I didn't really quite follow thought...

What I am trying to do in simple term is 2 tables:

Table1: ID, Name, Address, Phone
Table2: ID, Salary

And I am in the process of building PHP pages that will allow users to enter their own information and be put into the database.
Link to comment
https://forums.phpfreaks.com/topic/4992-picking-unique-id/#findComment-17637
Share on other sites

There's nothing about it that's hard to manage...every time a record is inserted into the db, it assigns it the next incremental id.

Potential table structure:
[code]
person
    ID
    Name
    Address
    Phone

workinfo
    ID
    personID
    Salary[/code]

sample query:

[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] Name, Address, Phone, Salary
[color=green]FROM[/color] [color=orange]person[/color] [color=green]LEFT[/color] [color=green]JOIN[/color] workinfo ON person.ID [color=orange]=[/color] workinfo.personID
[color=green]WHERE[/color] Name [color=orange]=[/color] [color=red]'Some Name'[/color] [!--sql2--][/div][!--sql3--]
Link to comment
https://forums.phpfreaks.com/topic/4992-picking-unique-id/#findComment-17640
Share on other sites

[!--quoteo(post=355172:date=Mar 14 2006, 08:17 PM:name=PupChow)--][div class=\'quotetop\']QUOTE(PupChow @ Mar 14 2006, 08:17 PM) [snapback]355172[/snapback][/div][div class=\'quotemain\'][!--quotec--]
do I also just join the table first if I want to delete a record?
[/quote]

No, you'll have to delete each of them.
Link to comment
https://forums.phpfreaks.com/topic/4992-picking-unique-id/#findComment-17644
Share on other sites

[!--quoteo(post=355175:date=Mar 14 2006, 08:22 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 14 2006, 08:22 PM) [snapback]355175[/snapback][/div][div class=\'quotemain\'][!--quotec--]
No, you'll have to delete each of them.
[/quote]

Would I need to do two different SQL queries for insert as well? Sorry, I am pretty new to this.
Link to comment
https://forums.phpfreaks.com/topic/4992-picking-unique-id/#findComment-17687
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.