Re: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Kevin (Gmail)
riginal Message - From: "Jerry Schwartz" To: "'Andre Matos'" ; "'Steven Staples'" Cc: Sent: Friday, May 28, 2010 6:51 PM Subject: RE: Using RAND to get a unique ID that has not been used yet -Original Message- From: Andre Matos [mailto

Re: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Perrin Harkins
On Fri, May 28, 2010 at 11:38 AM, Andre Matos wrote: > I have a table that uses auto_increment to generate the Id automatically > working fine. > However, I need to create a new table where the Id must be a number generated > randomly, so I cannot use the auto_increment. You'd be better off usin

Re: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Andre Matos
rom that table, and then delete that row? >>> >>> SELECT `column` FROM `table` ORDER BY RAND() LIMIT 1; >>> >>> >>> On a side note, I would use the auto-inc field still, and store this number >>> in another field. >>> >>> Steven Staples &

RE: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Jerry Schwartz
>-Original Message- >From: Andre Matos [mailto:andrema...@mineirinho.org] >Sent: Friday, May 28, 2010 1:44 PM >To: Steven Staples >Cc: mysql@lists.mysql.com >Subject: Re: Using RAND to get a unique ID that has not been used yet > >It seems to be a good approach,

RE: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Jerry Schwartz
>-Original Message- >From: Jim Lyons [mailto:jlyons4...@gmail.com] >Sent: Friday, May 28, 2010 11:49 AM >To: Andre Matos >Cc: mysql@lists.mysql.com >Subject: Re: Using RAND to get a unique ID that has not been used yet > >If your specs are that specific (IDs must

Re: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Andre Matos
; > > >> -Original Message- >> From: Jim Lyons [mailto:jlyons4...@gmail.com] >> Sent: May 28, 2010 11:49 AM >> To: Andre Matos >> Cc: mysql@lists.mysql.com >> Subject: Re: Using RAND to get a unique ID that has not been used yet >> >> If you

RE: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Steven Staples
> -Original Message- > From: Jim Lyons [mailto:jlyons4...@gmail.com] > Sent: May 28, 2010 11:49 AM > To: Andre Matos > Cc: mysql@lists.mysql.com > Subject: Re: Using RAND to get a unique ID that has not been used yet > > If your specs are that specific (IDs must be between

Re: Using RAND to get a unique ID that has not been used yet

2010-05-28 Thread Jim Lyons
If your specs are that specific (IDs must be between 1 and 99) then you could create a 99-row table with one integer column and prefill it with the numbers 1 to 99 in random order. Then you could write a function that would select and return the first number in the table, then delete t