i am a bit comfused about when do i have to use intersect in sql.The example that i am given is the following:
I have two tables:
MovieStar(name, address, gender, birthdate)
MovieExec(name, address, cert#, netWorth)
The example asks to find the name and address of all female actors who also are a movie executor and have networth over 10000000.The solution of the example in the book is the following:
(SELECT name, address
FROM MovieStar
WHERE gender = 'F')
INTERSECT
(SELECT name, address
FROM MovieExec
WHERE netWorth > 10000000);
So my problem is why i have to use INTERSECT while i could use the "AND" operator like:
SELECT name, address
FROM MovieStar, MovieExec
WHERE gender = 'F' AND netWorth > 10000000
Is there any tricky way to figure out when is better to use INTERSECT or "AND"?