vineet
vineet

Reputation: 14236

how fetch data from two table in codeigniter by using inner join

I am new for codeigniter and problem in Active Record(JOIN).

SELECT emp.name
    ,emp_detail.salary
FROM emp
INNER JOIN emp_details ON emp.id=emp_details.eid
                         AND emp_detail.salary > 5000

How to change above query in codeigniter.

Upvotes: 2

Views: 2060

Answers (1)

Narendrasingh Sisodia
Narendrasingh Sisodia

Reputation: 21437

You had typo within your query. I have updated yours into Active Records. This'll work for you..

$this->db->select('e.name,ed.salary');
$this->db->from('emp e');
$this->db->join('emp_details ed','e.id = ed.eid');
$this->db->where('ed.salary > 5000');
$result = $this->db->get()->result_array();
print_r($result);

Upvotes: 6

Related Questions