How to use not exists in a sql query with w3schools?

How to use not exists in a sql query with w3schools?

Im fairly certain that the problem lies in the way youre joining the correlated subquery, on orderid = orderid. Im not familiar with this dataset, but it seems surprising that the same order would have different shippers, and it adds a condition not found in your correct answer. This should work:

select o1.customerid
      ,o1.shipperid
from orders as o1
where o1.shipperid = 1 
and not exists (
    select o2.orderid 
    from orders as o2
    where o1.customerid = o2.customerid
    and o2.shipperid = 3)
order by customerid
;

How to use not exists in a sql query with w3schools?

Related Posts

Leave a Reply

Your email address will not be published.