我有这个问题:
SELECT *
FROM videos
WHERE Autor = 'LittleBabyBum ® Español'
ORDER BY RAND()
LIMIT 10)
UNION (
SELECT *
FROM videos
WHERE Categoría = 'Música - Niños'
AND Autor <>'LittleBabyBum ® Español'
ORDER BY RAND()
LIMIT 5
它的效果非常好。
但实际上我在codeigniter中有问题...有人知道如何使用它吗?
感谢。
答案 0 :(得分:0)
:
function result() {
$query = $this->db->query("(SELECT * FROM videos where Autor = 'LittleBabyBum ® Español' order by RAND() LIMIT 10) UNION (SELECT * FROM videos WHERE Categoría = 'Música - Niños' AND Autor <>'LittleBabyBum ® Español' order by RAND() lIMIT 5)");
return $query->result_array();
}
在控制器中:
$array = $this->MyModel->result();