Mysql RAND()

Discussion in 'MySQL' started by kjewat, Mar 8, 2006.

  1. #1
    Hi.

    I needed to generate a random number between n and m using mysql, so I looked up the RAND() function at mysql.com. At the mysql website I found the following statement:
    Further down on the page I found the following:
    Is the second statement correct? RAND() can return 1.0 right? In that case the example in the second statement would be
    SELECT FLOOR(7+(1.0*6))
    
    Code (markup):
    where the expression inside the parenthesis sums up to 13.0.
    SELECT FLOOR(13.0) returns 13 right? Thus, not between 7 and 12 (inclusive)

    Are the mysql website wrong, or am I missing something?
     
    kjewat, Mar 8, 2006 IP
  2. Phynder

    Phynder Well-Known Member

    Messages:
    2,603
    Likes Received:
    145
    Best Answers:
    0
    Trophy Points:
    178
    #2
    Hmmmm. Your example looks correct. Did you look at the comments below the documentation? People find errors all the time. Can you post a link to the version of the documentation you are looking at?
     
    Phynder, Mar 8, 2006 IP
  3. kjewat

    kjewat Active Member

    Messages:
    149
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    kjewat, Mar 8, 2006 IP
  4. kjewat

    kjewat Active Member

    Messages:
    149
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    kjewat, Mar 8, 2006 IP
  5. Dejavu

    Dejavu Peon

    Messages:
    916
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yeah its a documentation error.
    I dont think RAND() can produce a value of exactly 1, my guess is the first of the documentation is wrong.
     
    Dejavu, Mar 8, 2006 IP