MYSQL UNION ORDERING

后端 未结 4 567

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:38

    I got my answer from Joe Stefanelli, but modified it a bit:

    hi, i didn't need to make an artificial sort key, I just made sure that each table both had the same name of the column i wanted to sort on. In my case, the column name was "order". So I did:

    Select *, order as uOrder from table 1 
    UNION 
    select *, order as uOrder from table 2 
    ORDER BY uOrder
    

提交回复
热议问题