【发布时间】:2012-12-01 04:49:12
【问题描述】:
现在我的联接表返回第一个帖子行,我希望它具有每个主题的最后一行
这是我现在的代码
$this->db->select('*');
->where('disccategory_id', $cat);
->from('discussiontopics as topics');
->join('discussionposts as posts', 'posts.topic_id = topics.id', 'left');
->order_by('posts.id', 'desc');
->group_by('topics.id');
也许我只能通过连接内的选择来做到这一点?但不确定如何使用 Codeigniter 的 Active Record 来做到这一点
【问题讨论】:
-
你不能用相反的方式订购它并选择顶部吗?还是去底部?
-
$this->db->order_by('posts.id', 'asc');不会改变结果。我只得到一排