I searched this for a while but results are just confusing my head because I am quite new on MySQL.
I have a table with these 4 columns: AUTO_INCREMENT ID, NAME, TYPE, CHANCE
so rows look like this:
1, NOTHING, NO, 35
1, VERSICOLOR, TREE, 35
3, DIVERSIPES, TREE, 35
4, AMAZONICA, TREE, 35
5, EMILIA, GROUND, 25
6, BOEHMI, GROUND, 25
7, SMITHI, GROUND, 25
8, METALLICA, SKY, 5
9, REGALIS, SKY, 5
Note: Those are simple examples, there will be x100 like them. What I need to do is picking one row from this table with chances as shown in CHANCE
column.
Meaning; I need to pick one row from 9 of them and results can be "VERSICOLOR, DIVERSIPES, AMAZONICA or NOTHING with 35% chance" or "EMILIA, BOEHMI or SMITHI with 25% chance" or "METALLICA or REGALIS with %5 chance". So this query will probably give me the result of "VERSICOLOR, DIVERSIPES, AMAZONICA or NOTHING" because it has 35% chance or maybe I am gonna be lucky and I will get the "METALLICA or REGALIS" :)
Basicly there are 3 group of types, GROUND, TREE and SKY. What I want to do is getting only one result from all of these. GROUND, TREE or SKY type item with certain chances but to be certain, I dont want one for each group, I want only one result, it can be item of GROUND, TREE or SKY type. I hope that I did explain myself. Regards.