我想知道是否有可能选择有特殊条件的随机行。。。我解释说:选择属性为0的3行,但在我的3行中,我想要一个属性为1的行我有一张table“回复”像:表响应我想这样做:
SELECT * FROM reponse WHERE isTrue = 0 (and one of row(isTrue = 1) ORDER BY RAND() LIMIT 3
我不知道你是否真的明白我想做什么ps:我是法国人
zzwlnbp81#
解决方案:(selectfrom reponse where istrue=1 order by rand()limit 1)union all(selectfrom reponse where istrue=0 order by rand()limit 2)order by rand()非常感谢叶夫根尼!!
1条答案
按热度按时间zzwlnbp81#
解决方案:
(selectfrom reponse where istrue=1 order by rand()limit 1)union all(selectfrom reponse where istrue=0 order by rand()limit 2)order by rand()
非常感谢叶夫根尼!!