SELECT `blogposts`.*, `blog_category_uri`, `blog_category_title` FROM (`blogposts`, `blogcategories`) WHERE `blog_post_active` = 1 AND blog_post_created_on <= NOW() AND blog_post_category_id = blog_category_id ORDER BY `blog_post_priority` asc, `blog_post_created_on` desc, `blog_post_id` desc