mysql alphabetical order

前端 未结 8 1440
臣服心动
臣服心动 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:05

    Wildcard Characters are used with like clause to sort records.

    if we want to search a string which is starts with B then code is like the following:

    select * from tablename where colname like 'B%' order by columnname ;

    if we want to search a string which is ends with B then code is like the following: select * from tablename where colname like '%B' order by columnname ;

    if we want to search a string which is contains B then code is like the following: select * from tablename where colname like '%B%' order by columnname ;

    if we want to search a string in which second character is B then code is like the following: select * from tablename where colname like '_B%' order by columnname ;

    if we want to search a string in which third character is B then code is like the following: select * from tablename where colname like '__B%' order by columnname ;

    note : one underscore for one character.

提交回复
热议问题