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.. Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/86686-unique-id-random-string/#findComment-443021 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.