Sub Query in PHP

  1. Subqueries from Codeigniter using PHP
  2. Like This below Examples
  3. Ex

$this->db->select('o.*,a.company_name,sl.sub_locality as sublocation,st.name as state_name,d.district, (SELECT e.name FROM `employee` `e` WHERE `e`.`id` = `vme`.`marketing_executive_id`) as exec_names')->from('orders o')

     ->join('account a','a.id = o.customer_id')

    ->join('state st','st.id = a.state', 'LEFT')

     ->join('district d','d.id = a.district', 'LEFT')

     ->join('sub_location sl','sl.id = a.sub_locality', 'LEFT')

     ->join('vendor_marketing_executives vme','vme.acc_id = a.id') ;


Explanation:

If you are using more than two or more tables join to like this and if you want a particular employee name please go through this

Tagged:
Sign In or Register to comment.