I have this query:
$get_similar = $this->db->select('product.ar_id, product.title, likes.id, SUM(likes.up) as vote');
$get_similar = $this->db->from('product');
$get_similar = $this->db->join('likes', 'likes.id = product.id', 'left');
$get_similar = $this->db->where("MATCH (product.title, product.introduction) AGAINST ('$search') group by product.id LIMIT 6", null, false);
$get_similar = $this->db->get();
For each row I get vote = null
! It's supposed to return 0
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', 'likes.id = product.id', 'left');
you are joining likes.id with product.id, i think you want to join something like "likes.product_id" with "product.id"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.