UNION to replace LEFT JOIN


  • 0
    T

    SELECT s.name
    FROM salesperson s
    JOIN orders o
    USING (sales_id)
    WHERE s.sales_id NOT IN (
    SELECT o.sales_id
    FROM orders o, company c
    WHERE o.com_id = c.com_id AND c.name='RED'
    )
    UNION
    SELECT s.name
    FROM salesperson s
    WHERE s.sales_id NOT IN (
    SELECT o.sales_id
    FROM orders o
    )


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.