select c.id AS id,c.subject AS subject,c.date AS date,isnull(c.in_reply_to,id) AS irt, od.date AS org_date from blogcomments c, blogcomments od where isnull(c.in_reply_to, c.id) = od.id and c.blog_id = 1 ORDER BY od.date, c.date