how to display employee names starting with a and then b in sql

前端 未结 12 1623
谎友^
谎友^ 2021-02-05 19:58

i want to display the employee names which having names start with a and b ,it should be like list will display employees with \'a\' as a first letter and then the \'b\' as a

12条回答
  •  一整个雨季
    2021-02-05 20:47

    Oracle: Just felt to do it in different way. Disadvantage: It doesn't perform full index scan. But still gives the result and can use this in substring.

    select employee_name 
    from employees
    where lpad(employee_name,1) ='A'
     OR lpad(employee_name,1) = 'B'
    order by employee_name
    

    We can use LEFT in SQL Server instead of lpad . Still suggest not a good idea to use this method.

提交回复
热议问题