这很好用,但是当它返回少于 8 个结果时会出现问题。除了对缺少的其余结果重复查询之外,还有其他选择吗?任何帮助将不胜感激,谢谢。
$vacation = mysql_query("SELECT i.*
FROM vacation_offer_tbl i
INNER JOIN vacation_offer_pics_tbl c ON (c.vacat_offer_id = i.vacat_offer_id)
WHERE i.conditional ='1'
AND c.pic_1 != ''
// if < 8 results rerurn the rest where c.pic_1 ='nothing'
ORDER BY rand()
LIMIT 8") or die(mysql_error());