How to use substring in order by

后端 未结 2 1538
长发绾君心
长发绾君心 2021-01-28 21:34

I have the following query to select the domain names that have three levels separated by two dots:

select domainname from db.table
where criteria like (\'*.com\         


        
2条回答
  •  深忆病人
    2021-01-28 21:45

    You could use the function SUBSTRING_INDEX

    ORDER BY SUBSTRING_INDEX(domainname, '.', -2)
    

提交回复
热议问题