colombo colombo - 3 months ago 8
SQL Question

How to join two tables data in get_where clause in Codeigneitor

i want to join two tables in get_where can i do that?currently i have following code.

if ($dep == "0") {
$q = $this->db->get_where('pay', array("date" => $date));
} else {
$q = $this->db->get_where('pay', array("date" => $date, "dep" => $dep));

currently its getting data from pay table.what i want to do is at same time to check "status" field is "Active" in 'emp' table.i want to join that to $q.


Try below thing

 $q = $this->db->join('emp e',' = p.emp_id')->get_where('pay p', array("" => $date,"e.status"=>"Active"));