SELECT p.place_id, COALESCE(NULLIF(e.name, ''), p.name) AS name, IF(e.name IS NOT NULL AND e.name != '', 1, 0) AS has_edit_name, COALESCE(NULLIF(e.address, ''), p.formatted_address) AS formatted_address, IF(e.address IS NOT NULL AND e.address != '', 1, 0) AS has_edit_address, p.lat, p.lng, p.weighted_rating, p.composite_score, p.distance, COALESCE(NULLIF(e.redmond_category, ''), p.redmond_category) AS redmond_category, IF(e.redmond_category IS NOT NULL AND e.redmond_category != '', 1, 0) AS has_edit_redmond_category, COALESCE(NULLIF(e.redmond_search_term, ''), p.redmond_search_term) AS redmond_search_term, IF(e.redmond_search_term IS NOT NULL AND e.redmond_search_term != '', 1, 0) AS has_edit_redmond_search_term, COALESCE(NULLIF(e.types, ''), p.types) AS types, IF(e.types IS NOT NULL AND e.types != '', 1, 0) AS has_edit_types, COALESCE(NULLIF(e.website, ''), p.website) AS website, IF(e.website IS NOT NULL AND e.website != '', 1, 0) AS has_edit_website, COALESCE(NULLIF(e.phone, ''), p.formatted_phone_number) AS formatted_phone_number, IF(e.phone IS NOT NULL AND e.phone != '', 1, 0) AS has_edit_phone, CASE WHEN e.place_id IS NOT NULL THEN 1 ELSE 0 END AS has_edits, e.is_published
FROM wp_redmond_explorer_places p
LEFT JOIN wp_redmond_explorer_edits e ON p.place_id = e.place_id
WHERE 1=1 ORDER BY COALESCE(e.name, p.name) ASC LIMIT 650, 25