SELECT r1.response_id, r1.thread_id, r1.user_id, r1.rank, r1.nb_votes, r1.nb_helpfull_votes, r1.date, r1.message, r1.source_id, r1.spam, r2.response_id as parent_response_id, r2.user_id as parent_user_id, r2.rank as parent_rank, r2.date as parent_date, r2.message as parent_message, IF(IFNULL(o.user_id, 0) = 0, 0, 1) as online, IF(IFNULL(vhrp.user_id,0) = 0, 0, 1) as helpfull_for_author FROM z_responses_524 r1 LEFT JOIN z_responses_524 r2 ON (r2.response_id = r1.parent_response_id) LEFT JOIN online o FORCE INDEX (IX_UserID) ON (o.user_id = r1.user_id AND r1.user_id IS NOT NULL) LEFT JOIN threads AS t ON (t.thread_id = r1.thread_id) LEFT JOIN ( SELECT thread_id, response_id, user_id FROM vote_helpfull_responses_today GROUP BY thread_id, response_id, user_id ) AS vhrp ON (vhrp.thread_id = r1.thread_id) AND (vhrp.response_id = r1.response_id) AND (vhrp.user_id = t.user_id) WHERE r1.thread_id = 1017524 AND r1.rank BETWEEN 0 AND 6 ORDER BY r1.rank ASC