Categories
How to take a random record from a table, but so that the record ID of this record does not occur in another table?
Answer the question
In order to leave comments, you need to log in
SELECT * FROM `table1` WHERE `id` NOT IN( SELECT `id` FROM `table2` ) ORDER BY RAND() LIMIT 1
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question