colombo colombo - 1 year ago 80
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.

Answer Source

Try below thing

 $q = $this->db->join('emp e',' = p.emp_id')->get_where('pay p', array("" => $date,"e.status"=>"Active"));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download