1

I have following tables like below:

             product
         ----------------
         - id

         - rarity

         - name
rarity

s: lest chance
a
b

So, my question is that how can I random those data with probability with rarity? I know that inRandomOrder() will random data from database. But, How can I set where product that is rarity=s is lest chance to output?

Sok Chanty
  • 1,678
  • 2
  • 12
  • 22
  • Not sure if it can be done directly in sql. What you can do is pick 10 random items of rarity 'a', 8 (f.ex.) of rarity 'b' and 1 of rarity 's' and merge them in a collection. Then take a random pick from that collection. – Dimitri Mostrey Oct 01 '20 at 06:08
  • Thank @DimitriMostrey for your help. Is it take too much time? – Sok Chanty Oct 01 '20 at 09:17

0 Answers0