SELECT category_links.*, pages.*, categories.*, DATE_FORMAT(pages.news_date,'%d %M %Y') as displayDate FROM category_links,pages,categories WHERE pages.page_id = category_links.page_id AND categories.category_url = 'wa-news' AND categories.category_id = category_links.category_id AND pages.news_date <='2017-07-21' AND pages.member_page = 'no' AND pages.publish='yes' ORDER BY pages.news_date DESC LIMIT 20;