yaz Posted January 18, 2008 Share Posted January 18, 2008 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 More sharing options...
fenway Posted January 18, 2008 Share Posted January 18, 2008 Assuming you're hashing something of reasonable length, MD5() should give you something psuedo-unique enough. Link to comment https://forums.phpfreaks.com/topic/86686-unique-id-random-string/#findComment-443021 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.