If I run the following SQL query
SELECT *
FROM A
LEFT JOIN B
ON A.foo=B.foo
WHERE A.date = "Yesterday"
Does the WHERE
statement get evaluated before or after the JOIN
?
If after, what would be a better way to write this statement so that returns only rows in A
from "Yesterday"
are joined to B
?
It depends on the database.
On SQL Server, run: SET SHOWPLAN_ALL ON
then run the query, you will get an idea of what happens when it runs.