select object_type from contact_searches where search_id = :search_id select var_list from contact_search_conditions where type = 'group' and search_id = :search_id select distinct lam.attribute_id, a.pretty_name, a.attribute_name from ams_list_attribute_map lam, ams_lists l, ams_attributes a where lam.list_id = l.list_id and lam.attribute_id = a.attribute_id [template::list::page_where_clause -and -name "ams_options" -key "lam.attribute_id"] $extend_query $search_for_clause [template::list::orderby_clause -name "ams_options" -orderby] select distinct lam.attribute_id, a.pretty_name, a.attribute_name from ams_list_attribute_map lam, ams_lists l, ams_attributes a where lam.list_id = l.list_id and lam.attribute_id = a.attribute_id $extend_query $search_for_clause [template::list::orderby_clause -name "ams_options" -orderby] select 1 from contact_search_extend_map where search_id = :search_id and attribute_id = :attribute_id