RAND() generating same number in rapid sequence

Ask a Question related to MySQL, Design and Development.

  1. #1

    Default RAND() generating same number in rapid sequence

    I am using RAND() in rapid sequence, possibly on different connections.
    I expected to get different numbers from RAND(). I didn't. I get the same
    number within a given timeframe - it's like it's driven entirely by
    microtime.
    Am I stuck?

    I need different numbers for images. The only solution I can think of is to
    get 'the next image' from the database. to make it look random. but that's
    not very random.

    any ideas?


    Jim Michaels Guest

  2. Similar Questions and Discussions

    1. Is there a front end or rapid dev tool for flash??
      Those hundreds of small flash adds have to be made with some kind pf RAD rapid development tool. After some time with flash I still find the...
    2. Sequence Number Generator in IDS 9.4
      Anyone using or familiar with this new feature in IDS 9.4? We are wondering what it would take to convert from IDS 7.3 to 9.4 and implement this...
    3. Possible use for a continuation? [Generating all factors of agiven number]
      daz wrote: Darn! I was hoping to finally get a chance to use one :-). What I was really trying to achieve, though, was to have a generic...
    4. Possible use for a continuation? [Generating all factors of a given number]
      Harry Ohlsen <harryo@qiqsolutions.com> wrote: Overkill - this should do it: class MultiCounter def initialize(a, b = nil) @max = a @min =...
    5. sequence number in a view
      http://www.aspfaq.com/2427 "Max" <alvarez-m@att.net> wrote in message news:01d601c3417d$c083b3c0$a101280a@phx.gbl...
  3. #2

    Default Re: RAND() generating same number in rapid sequence


    "Peter H. Coffin" <hellsop@ninehells.com> wrote in message
    news:slrne4m0fr.mnd.hellsop@othin.ninehells.com...
    > On Sat, 22 Apr 2006 18:47:49 -0700, Jim Michaels wrote:
    >> I am using RAND() in rapid sequence, possibly on different
    >> connections. I expected to get different numbers from RAND(). I
    >> didn't. I get the same number within a given timeframe - it's like
    >> it's driven entirely by microtime. Am I stuck?
    >>
    >> I need different numbers for images. The only solution I can think of
    >> is to get 'the next image' from the database. to make it look random.
    >> but that's not very random.
    >>
    >> any ideas?
    >
    > Generate your random number on the application level? Use an
    tried that. same problem. no solution yet. microsecond resolution of
    uniqid() isn't fast enough to give me random images. this must be cached in
    memory at the server or something.
    > autoincrement column instead of a random one? Start with telling us what
    > problem you're trying to solve rather than telling us your not-working
    Trying to generate multiple random images by a onsie-script that selects one
    hopefully unique image (from an existing table of images that has id
    numbers) on a web page. At the very least, they should be different images
    from each other, so they *could* be sequential if I can't get random to
    work.
    > solution. That is, "I want to have a unique file name I can give to an
    > image associated with information stored in a table" instead of "RAND()
    > isn't random enough, so I can't make a file name out of it and guarantee
    > uniqueness".
    >

    Jim Michaels Guest

  4. #3

    Default Re: RAND() generating same number in rapid sequence


    "Jim Michaels" <NOSPAMFORjmichae3@yahoo.com> wrote in message
    news:fKKdnXFcNOVJsNHZnZ2dnUVZ_uWdnZ2d@comcast.com. ..
    >
    > "Peter H. Coffin" <hellsop@ninehells.com> wrote in message
    > news:slrne4m0fr.mnd.hellsop@othin.ninehells.com...
    >> On Sat, 22 Apr 2006 18:47:49 -0700, Jim Michaels wrote:
    >>> I am using RAND() in rapid sequence, possibly on different
    >>> connections. I expected to get different numbers from RAND(). I
    >>> didn't. I get the same number within a given timeframe - it's like
    >>> it's driven entirely by microtime. Am I stuck?
    >>>
    >>> I need different numbers for images. The only solution I can think of
    >>> is to get 'the next image' from the database. to make it look random.
    >>> but that's not very random.
    >>>
    >>> any ideas?
    >>
    >> Generate your random number on the application level? Use an
    >
    > tried that. same problem. no solution yet. microsecond resolution of
    > uniqid() isn't fast enough to give me random images. this must be cached
    > in memory at the server or something.
    >
    >> autoincrement column instead of a random one? Start with telling us what
    >> problem you're trying to solve rather than telling us your not-working
    >
    > Trying to generate multiple random images by a onsie-script that selects
    > one hopefully unique image (from an existing table of images that has id
    > numbers) on a web page. At the very least, they should be different
    > images from each other, so they *could* be sequential if I can't get
    > random to work.
    >
    >> solution. That is, "I want to have a unique file name I can give to an
    >> image associated with information stored in a table" instead of "RAND()
    >> isn't random enough, so I can't make a file name out of it and guarantee
    >> uniqueness".
    >>
    >
    >

    found the solution. the browser was cacheing the image and therefore giving
    me duplicates. the random number generator in the DB is fine. I don't have a
    "microtime" problem with it. All my thinking was bogus. I've been wrong
    before.


    Jim Michaels Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139