Hello,
I'm trying to convert this raw query to query builder :
Raw query :
Code:
SELECT a.id as ID, a.name as NAME, b.name as DEPT
FROM designations AS a
LEFT JOIN departments AS b ON b.id = a.department_id;
Query Builder :
Code:
$this->builder()
->select('a.id as id, a.name as name, b.name as dept_name')
->from('designations AS a')
->join('departments as b', 'b.id = a.department_id', 'left')
->get();
But query builder is not working as expected, I'm unable to echo the dept_name in the view, it returns null.