May 2019
Intermediate to advanced
542 pages
13h 37m
English
SELECT statements always return a single table of values. Even if your result set has only a single value, it will be in a table of one row and one column, and there is no way to return multiple tables from a single query. However, we can pull data from multiple tables by combining the data into a single table.
This can be done using a JOIN in the FROM clause, for example:
SELECT coffees.coffee_brand, coffees.coffee_name, roasts.description AS roast, COUNT(reviews.id) AS reviewsFROM coffees JOIN roasts ON coffees.roast_id = roasts.id LEFT OUTER JOIN reviews ON reviews.coffee_id = coffees.idGROUP BY coffee_brand, coffee_name, roastORDER BY reviews DESC;
In this case, our FROM clause contains two JOIN statements. The first joins ...
Read now
Unlock full access