Sorting a MySQL query with ORDER BY or with PHP sort functions

前端 未结 5 1139
深忆病人
深忆病人 2020-12-21 16:27

I have a query that I want to sort alphabetically, but the trick is that I want the sorting to treat two columns equally. For instance, if the first row of first_col<

5条回答
  •  庸人自扰
    2020-12-21 17:12

    Try

    ORDER BY CONCAT(b_name, l_name)
    

    or (if your fields are NULL when EMPTY)

    ORDER BY COALESCE(b_name, l_name)
    

提交回复
热议问题