我有这个问题:
$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();
对于每一行,我得到vote = null
!它应该只返回没有投票的产品0
!你能告诉我哪里弄错了吗?
答案 0 :(得分:0)
我认为你的错误就在这里:
$get_similar = $this->db->join('likes', 'likes.id = product.id', 'left');
你正在使用product.id加入likes.id,我想你想加入类似“likes.product_id”和“product.id”的东西