An Error Was Encountered
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') union (select distinct c.id as company_id, c.name, if(c.hide_address=1,'',c' at line 11
(select distinct c.id as company_id, c.name, if(c.hide_address=1,'',c.display_address) AS display_address, ci.name as city, ci.part_of, if(c.hide_phone=1,'',c.phone) as phone, c.long, c.lat, if(c.hide_website=1,'',c.website_en) as en_website, if(c.hide_website=1,'',c.website_en) as fr_website, c.total_monthly, 0 as franchise_id,direct_website_link, if(r.number_of_reviews,r.number_of_reviews,0) as number_of_reviews, if(bp.best_pick_selections_count,bp.best_pick_selections_count,0) as best_pick_selections_count, o.restaurant_id from companies c left outer join cities ci on ci.id=c.city_id left outer join reviews_summary_table r on r.company_id=c.id left outer join best_pick_companies bp on bp.company_id=c.id left outer join opentable o on o.company_id=c.id where c.franchise_id=41 and c.city_id=) union (select distinct c.id as company_id, c.name, if(c.hide_address=1,'',c.display_address) AS display_address, ci.name as city, ci.part_of, if(c.hide_phone=1,'',c.phone) as phone, c.long, c.lat, if(c.hide_website=1,'',c.website_en) as en_website, if(c.hide_website=1,'',c.website_en) as fr_website, c.total_monthly, 0 as franchise_id,direct_website_link, if(r.number_of_reviews,r.number_of_reviews,0) as number_of_reviews, if(bp.best_pick_selections_count,bp.best_pick_selections_count,0) as best_pick_selections_count, o.restaurant_id from companies c left outer join cities ci on ci.id=c.city_id left outer join reviews_summary_table r on r.company_id=c.id left outer join best_pick_companies bp on bp.company_id=c.id left outer join opentable o on o.company_id=c.id where c.franchise_id=41 and ci.part_of= and c.city_id<>) union (select c.id as company_id, c.name, if(c.hide_address=1,'',c.display_address) AS display_address, ci.name as city, ci.part_of, if(c.hide_phone=1,'',c.phone) as phone, c.long, c.lat, if(c.hide_website=1,'',c.website_en) as en_website, if(c.hide_website=1,'',c.website_en) as fr_website, c.total_monthly, 0 as franchise_id,direct_website_link, if(r.number_of_reviews,r.number_of_reviews,0) as number_of_reviews, if(bp.best_pick_selections_count,bp.best_pick_selections_count,0) as best_pick_selections_count, o.restaurant_id from companies c left outer join cities ci on ci.id=c.city_id left outer join reviews_summary_table r on r.company_id=c.id left outer join best_pick_companies bp on bp.company_id=c.id left outer join opentable o on o.company_id=c.id where c.franchise_id=41 and ci.part_of<> order by ci.name);