SELECT ud.user_id, CASE WHEN ud.listing_type = 'Individual' THEN CONCAT(ud.last_name,' ',ud.first_name) ELSE ud.company END AS name FROM `users_data` AS ud INNER JOIN `subscription_types` AS st ON ud.subscription_id = st.subscription_id WHERE ud.active = '2' AND st.searchable = '1' AND (st.search_membership_permissions REGEXP 'visitor' OR st.search_membership_permissions = '') ORDER BY st.search_priority ASC, name ASC, ud.user_id DESC