I need to be able to select 3 Unique random MySQL ID rows from a table that is progressively growing and growing over time, AND have a WHERE 'status' = 'available'. So it only picks the id number if status = available.
There will be no gaps as all data is kept for record keeping compliance, if data is deleted by the user it is not actually deleted just STATUS is marked 'deleted'.
I've read many posts about the subject but it all seems to boil down to picking just 1 result, and then repeating it 3 times, problem is, it might pick the same ID again, so any solution to my problem will be much appreciated.
Thank you
:)
I was looking at doing something like this (taken from here ... MySQL select 10 random rows from 600K rows fast)
SELECT id
FROM table AS r1 JOIN
(SELECT (RAND() *
(SELECT MAX(id)
FROM table)) AS id2)
AS r2
WHERE r1.id >= r2.id2 AND status = 'available'
ORDER BY r1.id ASC
LIMIT 1
Which gives me what I need, but it only returns 1 random Unique 'pick', plus IF I limit it to 3, it does not always pick 3, and if it does pick 3 they always seem to be sequential which is not random!
Is there a way to repeat the query, store the ID picked and keep looping / running the query until 3 ID's are picked AT RANDOM that are Different. This is my question :)