LIMIT LEFT JOIN TO RECORD FROM ADDED TABLE

时间:2021-12-13 16:27:07

Now the result is that it`s showing same post as many times as many photos it has. What to limit times of viewing same news??

现在的结果是,它显示了相同的帖子,就像它拥有的照片一样多。什么限制观看相同新闻的时间?

function get_all_news(){ 
   $query = $this->db->select('news.*, news_photos.name as news_photo_name, news_photos.ext as news_photo_ext')->from('news')->join('news_photos', 'news.id = news_photos.id_news', 'left')->order_by("date", "desc")->get();   
}

1 个解决方案

#1


0  

Try to use DISTINCT or a GROUP BY on news.id.

尝试在news.id上使用DISTINCT或GROUP BY。

#1


0  

Try to use DISTINCT or a GROUP BY on news.id.

尝试在news.id上使用DISTINCT或GROUP BY。