Minus vs Except Difference in ORACLE/SQL Server

前端 未结 2 1205
天涯浪人
天涯浪人 2020-12-14 18:26

MINUS is a SQL set operation that selects elements from the first table and then removes rows that are also returned by the second SELECT statement in Oracle. And in SQL Ser

2条回答
  •  醉话见心
    2020-12-14 18:31

    This will check for any result set from the first query, then run the except if there is a result. If not it only runs the second query.

    IF EXISTS (SELECT NULL
               FROM ... 
               WHERE ...)
    BEGIN
        SELECT ... 
        EXCEPT 
        SELECT ... 
    END
    ELSE
    SELECT ... 
    

提交回复
热议问题