Building a task listing for a task manager
This is really a SQL question, I'd encourage you to keep learning true SQL because it's a skill that's invaluable and it's increasingly not learnt thanks to the popularisation of noSQL solutions and abstraction heavy ORMs

To answer your question swap the direction of the query from tasks to projects instead of from projects to tasks, this will ensure you only get projects that have tasks, alternatively you could have added an extra condition in your where clause to exclude NULL tasks on the left join

or you can simply swap the left join to a normal join

$this-&gt;db-&gt;select("tasks.*, projects.project_name");
$this-&gt;db-&gt;from('tasks');
$this-&gt;db-&gt;where('projects.id', $project_id);
$this-&gt;db-&gt;join('projects', 'tasks.project_id = projects.id', "LEFT");
$this-&gt;db-&gt;order_by('tasks.created_date', 'DESC');
return $this-&gt;db-&gt;get()-&gt;result_array();