I’m creating an advertisement platform for my website, where we need select 3 rows randomly and number of times of banner display also should be balanced.
We can get the random rows like this,
SELECT column FROM table ORDER BY RAND() LIMIT 0,3
and we can balance the number of times by incrementing count field while selecting the row each time and select the rows with less count like this,
SELECT * FROM table ORDER BY display_count LIMIT 0,3.
But it will return the values like 1,2,3,4,5,6 and so. But i need to select rows with minimum count randomly. Any suggestion or idea on this would be great?
is this what you are looking for: