Sql server union but keep order

前端 未结 4 696
悲&欢浪女
悲&欢浪女 2020-12-05 09:58

Is there a way to union two tables, but keep the rows from the first table appearing first in the result set?

For example:

Table1

name                


        
4条回答
  •  庸人自扰
    2020-12-05 10:35

    Try this :-

    Select * 
    from
    ( 
    Select name,surname, 1 as filter
    from  Table1
    Union all
    Select name,surname , 2 as filter
    from Table2
    )
    order by filter
    

提交回复
热议问题