Topic: Randomnaja record with the given chance from other table
There are 2 tables storing the following data:
The task: to receive single line from the given list of subjects , increased by certain chance.
Tried to make it so (1 request):
SELECT * FROM ` items `, ` case_in ` WHERE items.id IN (2,3,4) ORDER BY RAND () *case_in.chance DESC LIMIT 1
But I understand that chances case_in.chance do not coincide in any way with the necessary lines.
Earlier the table was one, chances have been correlated to each subject the. The request was such (2 request):
SELECT * FROM ` items ` WHERE ` id ` IN (2,3,4) ORDER BY RAND () * ` chance ` DESC LIMIT 1
But such variant does not correspond to current requirements, therefore has been removed.
As a whole, the task dares sampling of lines from ` items `, to them corresponding ` chance ` on ` item_id `, and then operation of similarly second request, but I not especially understand, how it correctly to write.
How to receive similar result from the second request, but by means of these two tables?