0
$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");

I wrote this query using CI function but want it to be written in Active records way.

DanielBarbarian
  • 5,093
  • 12
  • 35
  • 44
  • Possible duplicate of [subquery in codeigniter active record](http://stackoverflow.com/questions/6047149/subquery-in-codeigniter-active-record) – Madhawa Priyashantha Oct 01 '16 at 12:10
  • Possible duplicate of http://stackoverflow.com/questions/15703992/codeigniter-active-record-nested-query – Rizwan Khan Oct 01 '16 at 12:18
  • Thanks for reply @FastSnail & GopaThemes . I have checked both links you've suggested. But it's not strict active record way of doing. Can you guys have any idea how can i do it that way. ? without writing full query as subquery. – user2622647 Oct 03 '16 at 06:26

0 Answers0