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

前端 未结 5 1141
深忆病人
深忆病人 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条回答
  •  猫巷女王i
    2020-12-21 17:14

    If your tables are very similar you can do this

    In my case I have a table test_a with 2 columns id and name

    (SELECT * FROM test_a a1) 
    UNION ALL 
    (SELECT * FROM test_a a2) 
    ORDER BY name DESC
    

提交回复
热议问题