Hello,
first of all, thank you for your replies!

second of all, i am not allowed to pick the same country more than once (the column 'country' is unique).
To make you understand the problem, here is mysql query, which selects 3 countries by random
without any sums:
Code:
SELECT * FROM `countries` ORDER BY rand() LIMIT 3
The valid result of this query may look like this:
country | number
=============
finland | 40
belarus | 15
germany | 30
As we can see, the sum of field, named "number", is 85 (40 + 15 + 30).
So, what i need is to add one more condition to query above:
the sum of randomly selected numbers must be less than 80. In this case,
finland(40) + belarus(15) + germany(30) = 85 is not valid result, because 85 is greater than 80.
In other words, mysql query should look something like this:
Code:
SELECT * FROM `countries`
WHERE sum_of_all_three_numbers_selected_randomly < 80
ORDER BY rand() LIMIT 3
I think subqueries must be used, but i'm not sure
I hope now you understood my problem

Waiting for your replies
