Multiple ascending order is not working in Mysql

后端 未结 2 1868
旧时难觅i
旧时难觅i 2021-01-26 01:37

I have one table called as request and there are three columns called as Id, want, teach. I have to display want and teach co

2条回答
  •  粉色の甜心
    2021-01-26 02:07

    first you need to understand order by

    if you give 1st,2nd asc order it will frist asc the 1st column and depend on this it will asc 2nd column. for example

    1st  2nd               
    1    b
    2    d
    3    a
    2    a
    1    a
    

    order by convert in

     1st   2nd 
      1     a
      1     b
      2     a
      2     d
      3     a
    

    So you need to different query

         SELECT want FROM request WHERE want IS NOT NULL OR want !='' GROUP BY 
     want ORDER BY want ASC
    
         SELECT teach FROM request WHERE teach IS NOT NULL OR teach !='' GROUP
     BY  teach ORDER BY teach ASC
    

提交回复
热议问题