Dylan Leblanc
04-23-2003, 11:42 AM
I have two tables I want to join in different ways to obtain different results. When I do an INNER JOIN everything works properly, but a LEFT JOIN seems to hang. This seems strange to me because the left join would not return many more rows than the inner join (by my calculations).
The two tables are named Building and Drawing. There are 7459 rows in the Building table and 11,270 rows in the Drawing table.
The relationship between them is that a building can have 0 to many drawings, and a drawing goes with one and only one building.
When I do a query with a INNER JOIN between the two tables it works fine, but a LEFT JOIN seems to hang.
The INNER JOIN returns 11,270 rows, like it should (because there are 11,270 drawings).
The LEFT JOIN should return 11,794 rows because there are 524 buildings without any drawings (11,270 + 524 = 11,794).
The LEFT JOIN query does not return a significantly larger number of rows. Why does it hang then?
SELECT *
FROM Building
INNER JOIN Drawing ON Drawing.buildingID = Building.buildingID;
SELECT *
FROM Building
LEFT JOIN Drawing ON Drawing.buildingID = Building.buildingID;
The two tables are named Building and Drawing. There are 7459 rows in the Building table and 11,270 rows in the Drawing table.
The relationship between them is that a building can have 0 to many drawings, and a drawing goes with one and only one building.
When I do a query with a INNER JOIN between the two tables it works fine, but a LEFT JOIN seems to hang.
The INNER JOIN returns 11,270 rows, like it should (because there are 11,270 drawings).
The LEFT JOIN should return 11,794 rows because there are 524 buildings without any drawings (11,270 + 524 = 11,794).
The LEFT JOIN query does not return a significantly larger number of rows. Why does it hang then?
SELECT *
FROM Building
INNER JOIN Drawing ON Drawing.buildingID = Building.buildingID;
SELECT *
FROM Building
LEFT JOIN Drawing ON Drawing.buildingID = Building.buildingID;