Jump to content

Unique ID = random string


yaz

Recommended Posts

Is there a way for MySQL to create a unique random string, without doing the random string in php, and/or without checking the table first for dupes?

 

ExampleTable

-----------------------------------------

TheID                  | TextValue       

 

a345dm4              | Random Text   

d41d8cd              | Random Text   

98f00b20              | more text

-----------------------------------------

 

TheID is already Unique.

 

Ideally I could do: INSERT INTO ExampleTable SET TextValue = "bla", and the statement crates the random string on its own.

 

I thought of doing:

 

INSERT INTO ExampleTable SET TextValue = "bla", TheID = MD5('')

 

But I'm not sure if mysql checks for the value to be unique without throwing me an error..

 

 

Link to comment
https://forums.phpfreaks.com/topic/86686-unique-id-random-string/
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.