MySQL Forums
Forum List  »  PHP

Re: Generate random unique IDs
Posted by: Rick James
Date: October 03, 2008 11:57PM

CREATE TABLE foo (
seq INT UNSIGNED AUTO_INCREMENT NOT NULL,
id type-of-your-id
);

INSERT INTO foo (id)
SELECT id FROM your-table ORDER BY rand();

Now foo has distinct integers from 1..N mapped to your ids.
Take things from there to put them into your table, or just join the tables as needed.

Options: ReplyQuote


Subject
Written By
Posted
September 17, 2008 01:58AM
September 17, 2008 10:28PM
September 24, 2008 05:08PM
January 29, 2009 08:09AM
January 29, 2009 11:58PM
September 30, 2008 07:58PM
Re: Generate random unique IDs
October 03, 2008 11:57PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.