SELECT
				saman_web_directories.sp_id,
				saman_web_directories.sp_title,
				saman_web_directories.sp_parent_id,
				saman_web_directories.sp_descrption,
				saman_web_directories.sp_keywords,
				saman_web_directories.sp_uid,
				saman_web_directories.sp_reg_date,
				saman_web_directories.sp_portal_id,
				saman_web_directories.sp_level,
				saman_web_directories.sp_order,
				CONCAT(saman_web_directories.sp_path, saman_web_directories.sp_id) path,
				saman_web_directories.sp_show_in_sitemap,
				saman_web_directories.sp_redirect_to,
				saman_web_directories.sp_no_page,
				saman_web_directories.sp_no_menu,
				saman_web_directories.sp_node_type,
				saman_web_directories.sp_image,
				saman_web_directories.sp_object_id,
				saman_web_directories.sp_lang,
				saman_web_directories.sp_is_system,
				saman_web_directories.sp_is_admin,
				saman_web_directories.sp_node_page_id,
				saman_web_directories.sp_edit_page_id,
				saman_web_directories.sp_view_page_id,
				(SELECT COUNT(*) FROM viw_content_media_gallery_items WHERE viw_content_media_gallery_items.web_directories LIKE CONCAT('%', saman_web_directories.sp_path, saman_web_directories.sp_id, '%') AND viw_content_media_gallery_items.record_state = 1000 AND viw_content_media_gallery_items.portal_id = 1047 AND viw_content_media_gallery_items.deleted = 0) AS rec_count
			FROM saman_web_directories
			    
			WHERE
				(saman_web_directories.sp_lang = 'en' OR saman_web_directories.sp_lang IS NULL OR saman_web_directories.sp_lang = '' OR saman_web_directories.sp_lang = 'all') AND
				saman_web_directories.sp_portal_id = '1047' AND ((saman_web_directories.sp_path LIKE '%/110875/%')) AND (sp_node_type IN (3, 4, 5)) AND (saman_web_directories.sp_lang = 'en' OR saman_web_directories.sp_lang = 'all' OR saman_web_directories.sp_lang IS NULL OR saman_web_directories.sp_lang = '') AND saman_web_directories.sp_node_type <> '-1'
			
			ORDER BY saman_web_directories.sp_path,saman_web_directories.sp_order