Let's say I have table [users] with the field [Name] and I've written a query in my application to search by name.
The names in the database are:
Lala Ally
My SQL query is:
SELECT * FROM users WHERE [Name] LIKE '%al%'
where 'al' is my search term.
How would I sort the results by search term found in the beginning i.e. '%al' and only afterwards '%al%'.
The result set should be
Ally Lala
I'm using SQL SERVER.
Thanks.