Sql - INTERSECT and EXCEPT
Code Life
By Pierre Marsaa
INTERSECT: in both lists
Look at this image, you know the two on top. The bottom row is this chapter:
The four set operators: the purple area is what each one keeps
INTERSECT keeps only the values that appear in both results. The cities that have a trainer and a gym:
↗️
Loading editor...
↶
↷
Same shape rules as UNION (same number of columns, same order), and the result is always distinct. Moonlight Hollow has a gym but no trainer, so it is out.
Verify