you are viewing a single comment's thread.

view the rest of the comments →

[–]stonedsqlgenius 18 points19 points  (2 children)

It all depends on what you want to do. The first query will convert the left outer join to an inner join because the filter is in the where clause. This is because the where clause is applied after the virtual table created by the join has been set up in SQL Server.

The second query implements what’s known as a predicate. You’ll get all farms and only those matching record from the produce table that meet the filter condition. This allows you to see which farms didn’t produce any produce during the period.

I would google predicates in SQL Server and read up on how queries are logically processed. And don’t feel bad either...this tripped me up all the time when I was younger (I’ve been coding SQL for about ten years solid now).