SELECT s.*, scd.*, scd.store_email as email, sc_header.content AS header_content, sc_ga.content as ga_alt, sc_footer.content AS footer_content, sc_bottom.content as bottom_content, CASE WHEN scd.open_monday IS NULL THEN 1 else 0 END AS monday_closed, CASE WHEN scd.open_tuesday IS NULL THEN 1 else 0 END AS tuesday_closed, CASE WHEN scd.open_wednesday IS NULL THEN 1 else 0 END AS wednesday_closed, CASE WHEN scd.open_thursday IS NULL THEN 1 else 0 END AS thursday_closed, CASE WHEN scd.open_friday IS NULL THEN 1 else 0 END AS friday_closed, CASE WHEN scd.open_saturday IS NULL THEN 1 else 0 END AS saturday_closed, CASE WHEN scd.open_sunday IS NULL THEN 1 else 0 END AS sunday_closed, CONCAT(scd.address_1, ' ', scd.address_2, ' ', scd.address_city, ' ', scd.address_postcode) as address FROM store s INNER JOIN store_contact_details scd ON s.store_id = scd.store_id LEFT JOIN store_content sc_header ON (sc_header.store_id = s.store_id AND sc_header.location = 'header') LEFT JOIN store_content sc_footer ON (sc_footer.store_id = s.store_id AND sc_footer.location = 'footer') LEFT JOIN store_content sc_bottom ON (sc_bottom.store_id = s.store_id AND sc_bottom.location = 'bottom') LEFT JOIN store_content sc_ga ON (sc_ga.store_id = s.store_id AND sc_ga.location = 'ga') WHERE url = 'http://www.chchemist.co.uk/' OR url = 'http://chchemist.co.uk/' AND s.active = 1