Exercise #23 page 4 |
||
The following solution uses join. Solution 1.15.5
The idea lies in the following: to have in derived table a column with a manufacturer's name, a column with speed of PC produced by this manufacturer, and also a column with speed of a laptop of the same manufacturer. Therefore, if the necessary restrictions on speeds will be imposed, the rows satisfying to these restrictions should give us what is necessary (a grouping on the manufacturer eliminates duplicates). The idea correct, however, what is joining is not that and not on those predicates which are expected. Really, the first INNER JOIN will give us the list of manufacturers and nos of PC models. But only of PCs, as model is a primary key in Product table . Therefore the second INNER JOIN with Laptop table (on model column!) will give us empty result set, as none of PCs is present (and cannot be!) in Laptop table. To achieve this idea, it is necessary to join the manufacturers of the necessary PCs with corresponding manufacturers of laptops not on model, but on the name of the manufacturer, or to use outer join instead of inner join. |