Suppose I have a column named CustomerNames in database with values:
- Vins et alcools Chevalier
- Magazzini Alimentari Riuniti
- Hungry Owl All-Night Grocers
- Split Rail Beer & Ale
- Alfreds Futterkiste
I want to make a query which will search only for the first letters of FIRSTNAME and LASTNAME, and list the names in ASC order based on FIRSTNAME then LASTNAME. for example if I search for "al" in above table, it should return me something like below:
- Alfreds Futterkiste
- Vins et alcools Chevalier
- Split Rail Beer & Ale
- Magazzini Alimentari Riuniti
- Hungry Owl All-Night Grocers
I have used below query.
SELECT * FROM Customers where CustomerName LIKE 'al%' OR CustomerName LIKE '% al%' ORDER BY CustomerName
Output:
- Alfreds Futterkiste
- Hungry Owl All-Night Grocers
- Magazzini Alimentari Riuniti
- Split Rail Beer & Ale
- Vins et alcools Chevalier
Which is ordering results only on the basis of firstnames. But I want a query which gives output using firstnames and then lastnames. Thanks.