Implemented helper function for query 'select'