List:General Discussion« Previous MessageNext Message »
From:Jerry Schwartz Date:October 16 2009 4:57pm
Subject:RE: insert random number into table
View as plain text  
There is a RAND function in MySQL, but if you need to guarantee that the 
identifiers are unique you should consider using an auto-increment field.

If that isn't unique enough, you can use the UUID or UUID_SHORT functions. 
Theoretically, those should return values that are unique across the Internet 
(at least).

Regards,

Jerry Schwartz
The Infoshop by Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341

www.the-infoshop.com


>-----Original Message-----
>From: Ray [mailto:ray@stripped]
>Sent: Friday, October 16, 2009 11:43 AM
>To: mysql@stripped
>Subject: insert random number into table
>
>Hello All,
>I am trying to insert a unique random number* with each row when inserting
>into a table. I can do it in the application layer (php) but just wondering 
>if
>there is an easier way in the database layer.
>Thanks
>Ray
>
>* for example, when registering a person for a contest, I want to give them a
>unique, random identifier.
>
>--
>MySQL General Mailing List
>For list archives: http://lists.mysql.com/mysql
>To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>infoshop.com




Thread
insert random number into tableRay16 Oct
  • RE: insert random number into tableJerry Schwartz16 Oct
    • Re: insert random number into tableRay16 Oct
      • RE: insert random number into tableJerry Schwartz16 Oct
        • Re: insert random number into tableScott Haneda16 Oct
          • RE: insert random number into tableJerry Schwartz19 Oct
        • Re: insert random number into tableRay17 Oct
  • RE: insert random number into tableGavin Towey16 Oct
    • Re: insert random number into tableScott Haneda16 Oct