I have a table that describes a variety of objects in my system (ie. umbrella, boots, satchel, whatever). Each one of these objects needs to have a distinct prevalence or incidence. For example, the umbrella is rarer than the boots. Based on those factors, I need to randomly select a single object (including a blank or 'no object found') based on that incidence value.
Yikes. Make sense?
SELECT * FROM some_table
WHERE (100*RAND()) > some_table.percent_probability
LIMIT 1
....and the probability of selection is stored in the percent_probability field.
C.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With