I have this query:
update posts 
set rank = (SELECT FIND_IN_SET( CONCAT(points, '_', comments_count, '_', created_at), 
    (SELECT GROUP_CONCAT( CONCAT(points, '_', comments_count, '_', created_at) ORDER BY points desc, comments_count desc, created_at desc ) 
FROM (select *, COUNT(comments.id) as comments_count from posts) as posts_rankings INNER JOIN comments ON comments.post_id = posts_rankings.id)))
I want get count of comments on every post and next orderBy with this count. How I can do this? Now me get error:: unknown column comments.id in field list
My tables structure:
I calculate rank of post depending on order the points, comments_count and created_at. 


 
    