mysql alphabetical order

前端 未结 8 1441
臣服心动
臣服心动 2021-02-04 05:34

i am trying to sort mysql data with alphabeticaly like

A | B | C | D

when i click on B this query runs

select name from user order by \

相关标签:
8条回答
  • 2021-02-04 06:24

    You can use:

    SELECT name FROM user WHERE name like 'b%' ORDER BY name
    
    0 讨论(0)
  • 2021-02-04 06:32

    but result showing all records starting with a or c or d i want to show records only starting with b

    You should use WHERE in that case:

    select name from user where name = 'b' order by name
    

    If you want to allow regex, you can use the LIKE operator there too if you want. Example:

    select name from user where name like 'b%' order by name
    

    That will select records starting with b. Following query on the other hand will select all rows where b is found anywhere in the column:

    select name from user where name like '%b%' order by name
    
    0 讨论(0)
提交回复
热议问题