i have a mysql query like:
select * from employee
where name like '%ani%'
I want my results to be order by starting with ani for eg. my results should be comming as: {anil,anirudha,rani, ...} starting with ani first and then followed by other characters.
Can anybody please help me on this.
Something like
select * from employee where name like '%ani%' order by locate('ani', name) asc, name asc
Should do the trick ... (sort by position of the substring in the whole string)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With