Is it possible to write single query for exact match and partial match

Thank you