php - how to return 0 during count in codeigniter


I have tables "skill_rating" and "skill_description". descriptionId column of skill_description is foreign key in skill_rating. I want to count the number of staffId for each description with rating 2.

$query1=$this->db->select('skill_description.description, count(staffId) as experienced')
                       ->join('skill_description','skill_rating.descriptionId = skill_description.descriptionId')
                       ->where_in ('skill_description.descriptionId',$id)
                       ->where ('skill_rating.rating','2')
                       ->order_by("skill_description.description asc")

This only returns me results with description having non zero count meaning it does not gives count 0 for description with zero counts. i have tried coalesce but no difference. i want result with 0 for descriptions that do not have rating 2. what should i do?

People are also looking for solutions to the problem: sql - PHP - ORA-01747: invalid user.table.column, table.column, or column specification


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.