Jump to content

generating a unique ID in mysql table


suckablesausage

Recommended Posts

[code]mysql_query("CREATE TABLE IF NOT EXISTS `tablename` (`id` int(11) not null auto_increment, `field1` text(80) not null, `field2` text(80) not null, primary key (id))") or die(mysql_error());[/code]

The id field will be incremented automatically so it will be unique. If you use phpMyAdmin or something of that nature you can set all of these things while creating the table through the user interface.
[!--quoteo(post=360191:date=Mar 30 2006, 03:07 PM:name=jireh)--][div class=\'quotetop\']QUOTE(jireh @ Mar 30 2006, 03:07 PM) [snapback]360191[/snapback][/div][div class=\'quotemain\'][!--quotec--]
hello gurus =)

i was wondering how to generate a unique ID so it can be put in mysql.
am i making sense?
[/quote]
oh oh I think I can answer this one for ya! (Im new myself). If you mean you want a unique number for lets say a user name I use the Auto-Increment.

Michelle

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.