Exercise #6 (tips and solutions)
Exercise #6 (tips and solutions)
There are two ways to perform a table join (in this case, an inner join is needed):
- Using a WHERE clause (the only option before the SQL-92 standard has been introduced)
SELECT DISTINCT Product.maker, Laptop.speed
FROM Product, Laptop
WHERE Product.model = Laptop.model
AND Laptop.hd >= 10;
mssql
🚫
[[ error ]]
[[ column ]] |
---|
[[ value ]] |
- Explicit use of a JOIN statement
SELECT DISTINCT Product.maker,Laptop.speed
FROM Product JOIN
Laptop ON Product.model = Laptop.model
WHERE Laptop.hd >= 10;
mssql
🚫
[[ error ]]
[[ column ]] |
---|
[[ value ]] |
Although the SQL Server query optimizer will generate identical execution plans for both queries, the second alternative is preferable, since it allows to keep apart join conditions and row filtering criteria.