embedding LEFT OUTER JOIN within INNER JOIN

Posted by user3424954 on Programmers See other posts from Programmers or by user3424954
Published on 2014-08-18T17:44:34Z Indexed on 2014/08/18 22:31 UTC
Read the original article Hit count: 396

Filed under:
|

I am having some problems with one of the question's answered in the book "SQL FOR MERE MORTALS".

Here is the problem statement

Problem Statement

Here is the Database Structure

The Database Structure

Here is the answer which I am unable to comprehend

DoubtFul Answer

Here is an answer which looks perfect to me

Confirmed Answer

Now the problem with the first answer I am having is: We first use LEFT OUTER JOIN for recipe class and recipes. So it selects all recipe class rows but only matching recipes. Perfecty fine as the question is demanding. Lets call this result set R. Now in the next step when we use INNER JOIN to join RecipieIngridients, it should filter out the rows from R in which Recipie ID doesn't match with the Recipe Id in Recipie Ingredients and hence filtering out the related Recipe class and recipe description also(Since it filters out the entire row of R). So this contradicts with the problem which demands all recipieID and RecipieDescription to be displayed from Recipe_Classes Table in this very step only. How can it be correct. Or Am i Missing some concept.

© Programmers or respective owner

Related posts about sql

Related posts about mysql