I assume the RAND() function can be used in in an insert:
INSERT INTO target (MyRandVal, OtherColumns)
VALUES (RAND() * (MaxVal - MinVal) + MinVal, OtherData)
OR
INSERT INTO target (MyRandVal, OtherColumns)
SELECT RAND() * (MaxVal - MinVal) + MinVal, OtherData
FROM ...
HTH,
Tore.
----- Original Message -----
From: "1LT John W. Holmes" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Scott Brown"
<[EMAIL PROTECTED]>
Sent: Wednesday, February 26, 2003 3:59 PM
Subject: Re: Random 32bit number for columns?
> > I am trying to find a means to create a column that self-populates with
> > unique random 32bit integers in MySQL.
> >
> > Do I need to do this in code, or is there a column spec/extra that I can
> > use to populate a column with random numbers on an insert? Ideally, the
> > database itself would manage this column...
>
> The defaults for a column must be a constant. You'll have to do this in
> code.
>
> ---John Holmes...
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php