WordPress database error Not unique table/alias: 'wp_comments' for query SELECT SQL_CALC_FOUND_ROWS wp_posts.*, AVG( wp_commentmeta.meta_value ) as average_rating , AVG( wp_commentmeta.meta_value ) as average_rating, SUM( wp_comments.comment_approved ) as sum_of_comments_approved FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) LEFT OUTER JOIN wp_comments ON(wp_posts.ID = wp_comments.comment_post_ID) LEFT JOIN wp_commentmeta ON(wp_comments.comment_ID = wp_commentmeta.comment_id) LEFT OUTER JOIN wp_comments ON(wp_posts.ID = wp_comments.comment_post_ID) LEFT JOIN wp_commentmeta ON(wp_comments.comment_ID = wp_commentmeta.comment_id) WHERE 1=1 AND ( ( wp_postmeta.meta_key = '_visibility' AND CAST(wp_postmeta.meta_value AS CHAR) IN ('visible','catalog') ) ) AND wp_posts.post_type = 'product' AND (wp_posts.post_status = 'publish') AND ( wp_commentmeta.meta_key = 'rating' OR wp_commentmeta.meta_key IS null ) AND ( wp_commentmeta.meta_key = 'rating' OR wp_commentmeta.meta_key IS null ) GROUP BY wp_posts.ID ORDER BY sum_of_comments_approved DESC, average_rating DESC, wp_posts.post_date DESC LIMIT 0, 12 made by require('D:\website\ganothailand.com\httpdocs\homewp\wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts