[two tables-ta and tb with respective columns ]
I was asked to put a LEFT JOIN on item id and explain what would be the possible output. I wrote a pseudocode like this-
x
SELECT
table a.ITEM ID,
table a.ITEM NAME,
table b.ITEM ID,
table b.ITEM NAME
from
table a
LEFT JOIN table b ON table a.ITEM ID = table b.ITEM ID;
I told them the output would look like this, which they told is not the right answer.
ITEM ID ITEM NAME ITEM ID ITEM NAME
-1 X -1 P
-1 Y -1 Q
-1 Z -1 R
-1 W
Can anyone explain what would be the correct answer along with logic?
Advertisement
Answer
if the data in the screenshot was the data they gave you , all item ids are -1 which means no matter if you do inner join or outer join , its gonna be a cross join meaning you will have all combination of table1 with table 2 which will be 12 rows