I would like to know if it's possible to select random row with special condition...
I explain myself:
select 3 row with attribut isTrue = 0 but in my 3 row i want one with isTrue = 1
I've a table "reponse" like:
I would like to do something like that:
SELECT * FROM reponse
WHERE isTrue = 0 (and one of row(isTrue = 1)
ORDER BY RAND()
LIMIT 3
I don't know if you realy understood what i want to do PS: I'm french
Solution:
(SELECT * FROM reponse WHERE isTrue = 1 ORDER BY RAND() LIMIT 1) union all (SELECT * FROM reponse WHERE isTrue = 0 ORDER BY RAND() LIMIT 2) ORDER BY RAND()
Thank you very much Evgeny !!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.