php - sum of table's column return null (codeigniter) using left join


I have this query:

$get_similar = $this->db->select('product.ar_id, product.title,, SUM(likes.up) as vote');
$get_similar = $this->db->from('product');
$get_similar = $this->db->join('likes', ' =', 'left');
$get_similar = $this->db->where("MATCH (product.title, product.introduction) AGAINST ('$search') group by LIMIT 6", null, false);
$get_similar = $this->db->get();    

For each row I getvote = null! It's supposed to return0 for only the products that don't have votes! Can you tell me where I made a mistake, please?




I think your error is here:

$get_similar = $this->db->join('likes', ' =', 'left');

you are joining with, i think you want to join something like "likes.product_id" with ""

People are also looking for solutions to the problem: PHP Sorting by turns


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.