Why Left Join for SQL Joins Using WHERE or ON Practice Problem 1

So I am going through tutorials and I am at SQL Joins Using WHERE or ON Practice Problem 1

In the solution Query uses Left Join, while I get same results with simple inner Join.

When I use Left Join I need to filter out Null Status values.

Why does Query use Left Join.

1reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
  •  Hi MP - The results of using an INNER JOIN vs a LEFT JOIN are not quite the same. The difference is that by using a LEFT JOIN, you'll return all companies from the companies table (even those which do not have records in the investments table). This means that some companies will return a unqiue_investors count of 0. Whereas if you use an INNER JOIN, you will only return rows for companies that also have a record in the investments table.

    Since the instructions for that practice problem don't mention excluding companies without investments, a LEFT JOIN is the approach I would take here.

    Reply Like 1
Like Follow
  • Status Answered
  • 9 mths agoLast active
  • 1Replies
  • 296Views
  • 2 Following

Create A New Discussion

Share your thoughts