How to execute UNION without sorting? (SQL)

前端 未结 10 613
猫巷女王i
猫巷女王i 2021-01-30 21:34

UNION joins two results and remove duplicates, while UNION ALL does not remove duplicates.
UNION also sort the final output.

W

10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-30 21:51

    I assume your tables are table1 and table2 respectively, and your solution is;

    (select * from table1 MINUS select * from table2)
    UNION ALL
    (select * from table2 MINUS select * from table1)
    

提交回复
热议问题