I have a table of 16K records
I want to extract random 44 entries
but I donβt want to repeat the same entries more than once (ever)
therefore, I have a list for each user that stores the already used "IDs" as a string, separated by commas in the table.
and I use this list for SELECT ... NOT IN (used_IDs)
The problem is that this list is getting too big and sql call fails due to the size that I consider
Any idea on how to make this more useful?
Questions table: +------+-------+-------+ | id | Qtext | Tags | +------+-------+-------+ Test table: +------+-------+ | id | QIDs | +------+-------+ Results table: +------+-------+-------+ | id | tID | uID | +------+-------+-------+
I need to select unique random values ββfrom the Questions table based on the results table. (which associates test id with question IDs)
Currently trying to use:
SELECT DISTINCT `questions`.`ID` FROM `questions`, `tests`, `results` WHERE `questions`.`ID` NOT IN (`tests`.`qIDs`) AND `results`.`uID` = 1 AND `tests`.`ID` = `results`.`tID` AND 4 IN ( `questions`.`tags`) AND "http://www.usmlestep2qna.com" = `provider` ORDER BY RAND() LIMIT 27;
Any ideas?
source share