The Difference Between INNER and LEFT JOINs in SQL

SQL joins are fundamental operations in relational databases, allowing us to combine data from multiple tables. Two of the most commonly used join types are INNER JOIN and LEFT JOIN. Understanding the difference between these joins is crucial if you intend to use joins in your queries.

In this article, we’ll look at the difference between the INNER JOIN and LEFT JOIN using a simple example.

Continue reading

Override the Query Optimizer for your T-SQL Joins with FORCEPLAN

The SET FORCEPLAN statement overrides the logic used by the SQL Server query optimizer to process a T-SQL SELECT statement.

More specifically, when FORCEPLAN is set to ON, the query optimizer processes a join in the same order as the tables appear in the FROM clause of a query.

This also forces the use of a nested loop join unless other types of joins are required to construct a plan for the query, or they are requested with join hints or query hints.

Continue reading