NOT IN subquery + Left JOIN


  • 1
    S
    SELECT name
    FROM salesperson
    WHERE sales_id NOT IN (
        SELECT sales_id
        FROM orders LEFT JOIN company 
        ON orders.com_id = company.com_id
        WHERE company.name = 'RED'
    )
    ORDER BY name
    

  • 0
    P

    @siwest said in NOT IN subquery + Left JOIN:

    SELECT name
    FROM salesperson
    WHERE sales_id NOT IN (
    SELECT sales_id
    FROM orders LEFT JOIN company
    ON orders.com_id = company.com_id
    WHERE company.name = 'RED'
    )
    ORDER BY name

    Can let us know reason behind using left join in the inner query. I think it is not required. But let me know if i am wrong.


  • 0
    L

    I think left join is wrong, it should not be used.


Log in to reply
 

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