如何在Active recorder Codeigniter方式中编写多个子查询?

时间:2016-10-01 12:06:02

标签: php mysql codeigniter activerecord

$levelsql =$this->db->query("SELECT pro_id,pro_xp,pro_label
    FROM
    (
        SELECT *, 
        (
          SELECT SUM(pro_xp)
            FROM tbl_program
            WHERE pro_xp <= t.pro_xp
        ) total
        FROM tbl_program t
    ) q
   WHERE total <= $ProfileXp
   ORDER BY pro_xp desc");

我使用CI函数编写了此查询,但希望以Active记录方式编写。

0 个答案:

没有答案