MYSQL UNION ORDERING

后端 未结 4 564

Is it possible to order the first enquiry and keep the rows returned as first and not order the second enquiry. (If that makes sence)

An example of my current enquir

4条回答
  •  长发绾君心
    2021-01-12 07:35

    You could fake it

    SELECT col1, col2 ... 
    FROM (
      SELECT 1 fake_order, col1, col2 ... FROM Devices WHERE Live ='true' AND Category='apple' ORDER BY ListOrder
      UNION ALL
      SELECT 2, col1, col2 ... FROM Devices WHERE DeviceLive ='true'
    ) AS T 
    ORDER BY fake_order
    

    (Untested SQL off the top of my head)

提交回复
热议问题