1021 -

( SELECT 0 as xs, pd.pages_name, pd.pages_name_mobile, p.pages_id,pd.url_amigable, p.show_in_modal, p.pages_key, p.has_link, p.category_id, p.category_menu, p.target_category, p.margin_left, p.margin_right, p.separation_left, p.separation_right, p.orientation, p.icon_from_categories, p.sort_order, p.destacado_header, p.destacado_mobile, p.menu_mid, p.menu_inferior, p.hide_menu_title, p.menu_width, p.navbar_type, p.display_custom_list, ( SELECT COUNT(1) AS submenu FROM pages p2 WHERE p2.parent_id = p.pages_id AND p2.pages_status = 1 ) AS submenu, p.link, p.target FROM pages p LEFT JOIN pages_description pd ON p.pages_id = pd.pages_id WHERE p.destacado_header=1 AND p.pages_id = pd.pages_id AND pd.language_id=2 AND p.pages_status = 1 AND p.parent_id = 0 and p.pages_id != 89 and p.pages_id != 91 and p.show_to_user_logged = 0 ) UNION ( SELECT 1 as xs, pd2.pages_name, pd2.pages_name_mobile, p2.pages_id,pd2.url_amigable, p2.show_in_modal, p2.pages_key, p2.has_link, p2.category_id, p2.category_menu, p2.target_category, p2.margin_left, p2.margin_right, p2.separation_left, p2.separation_right, p2.orientation, p2.icon_from_categories, p2.sort_order, p2.destacado_header, p2.destacado_mobile, p2.menu_mid, p2.menu_inferior, p2.hide_menu_title, p2.menu_width, p2.navbar_type, p2.display_custom_list, ( SELECT COUNT(1) AS submenu2 FROM pages p22 WHERE p22.parent_id = p2.pages_id AND p22.pages_status = 1) AS submenu2, p2.link, p2.target FROM pages p2 LEFT JOIN pages_description pd2 ON p2.pages_id = pd2.pages_id WHERE p2.pages_id = pd2.pages_id AND pd2.language_id=2 AND p2.pages_status = 1 AND p2.parent_id = 0 AND p2.pages_key in ("CATEGORIES_MENU") ) ORDER BY CASE WHEN pages_key="CATEGORIES_MENU" AND xs=1 THEN -2 ELSE 1 END, sort_order