There is two table: user, comments
The structure is like this:
user
-----
id
name
comments
--------
id
title
user_id
comments_id
Notice that the comments_id is the parent ID of that comment record, that means, if comments_id is null, it is a POST, if it is not null, it is a REPLY.
So I would like to select them and ordering like this
Post 1
Reply 1 for Post 1
Reply 2 for Post 1
Post2
...
And here is the codeigniter query I have attempt, I also need the user table for getting the user name
$this->db->select('c.id as id, u.name as username, c.txtMsg as txtMsg, c.createDate as createDate, c.updateDate as updateDate, c.imageURL as imageURL, c.postID as postID');
$this->db->from('comment as c, user as u');
$this->db->where('u.id = c.userID');
$this->db->order_by('c.id', $order_type);
How to construct the query to order the list? Thanks for helping.