Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a double not exists clause mean?

SELECT c.name
FROM   Customer c
WHERE  NOT EXISTS(SELECT w.WID
                  FROM   Woker w
                  WHERE  NOT EXISTS(SELECT la
                                    FROM   look_after la
                                    WHERE  la.CID = c.CID
                                           AND la.WID = w.WID)); 

I dont know what the code means... Could anyone tell me broadly what the code do? C is a Customer, who will looked after from a Worker.

like image 879
Halso Johnson Avatar asked Dec 27 '22 01:12

Halso Johnson


1 Answers

The query selects customers that are looked after by all workers.

The double not exists is a way to implement relational division.

like image 158
Andomar Avatar answered Dec 28 '22 13:12

Andomar