Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2013
    Posts
    1

    Unanswered: SELECT RANDOM with odds

    Hi, I would like to SLECT a random entry, so I use :
    ORDER BY RAND() LIMIT 1

    But I want to get it according to "odds",
    I would like :
    80% of entry with label "blue" (8 chances up to 10 on each SELECT), and
    20% of entry with label "red" (2 chances up to 10 on each SELECT)

    How could I do ?

    Merci,
    Sylvain.

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    fake it?
    run two selects,
    ...one pulls 8 rows from your 'blue group'
    ...the other pulls 2 rows from your 'red group
    using a where clause to limit to the sepcified group
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Or select a random number. If the number is less or equal to 0.8 select a row from blue and if it is greater than 0.8 select one from red.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Posting Permissions

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