I have this select scenario:
I would like to return exact matches first, then only check for partial matches progressively, using a simple T-sql query.
select * from accounts where
mobile = @mobile or
mobile like @mobile +'%' or
mobile like '%'+@mobile or
mobile like '%'+@mobile +'%'
I understand that T-sql
performs All-At-Once Operations.
How best can this be achieved?
You could evaluate in a CASE and provide a ranking value: