I've this query:
SELECT DISTINCT `default_wall_posts_comments`.`c_id` as c_id,
`default_wall_posts_comments`.`comments` as comments,
UNIX_TIMESTAMP() - default_wall_posts_comments.date_created AS pass_time_comment,
`default_profiles`.*, `default_wall_posts`.*,
UNIX_TIMESTAMP() - default_wall_posts.date_created AS pass_time
FROM (`default_wall_posts`)
LEFT JOIN `default_profiles`
ON `default_profiles`.`user_id` = `default_wall_posts`.`userid`
LEFT JOIN `default_wall_posts_comments`
ON `default_wall_posts`.`p_id` = `default_wall_posts_comments`.`post_id`
WHERE `default_wall_posts`.`userid` = '1'
ORDER BY `default_wall_posts`.`date_created` DESC LIMIT 7
But results for the main table which is default_wall_posts
are repeated for each default_wall_posts_comments
.
I'm trying to get all comments for one default_wall_posts
. Can be this query optimized in some way?