Database Reference
In-Depth Information
AND families.order_id = 102
AND common_name != ''
ORDER BY common_name LIMIT 10, 5;
+------------------+------------------+-----------------+
| Bird | Family | Order |
+------------------+------------------+-----------------+
| Ancient Murrelet | Alcidae | Charadriiformes |
| Andean Avocet | Recurvirostridae | Charadriiformes |
| Andean Gull | Laridae | Charadriiformes |
| Andean Lapwing | Charadriidae | Charadriiformes |
| Andean Snipe | Scolopacidae | Charadriiformes |
+------------------+------------------+-----------------+
Let's look at the changes from the previous statement to this one. We added the third table
to the FROM clauseand gave it an alias of orders . To properly connect the third table,
we had to add another evaluator to the WHERE clause: families.order_id = or-
ders.order_id . This allows the SELECT to retrieve the right rows containing the sci-
entific names of the orders that correspond to the rows we select from the families. We
also added a column to the field list to display the name of the order. Because the families
we've selected are all from the same order, that field seems a little pointless in these res-
ults but can be useful as we search more orders in the future. We gave a starting point for
the LIMIT clause so that we could see the next five birdsin the results.
NOTE
It's not necessary to put the field alias name for a column in quotes if the alias is only one word.
However, if you use a reserved word (e.g., Order ), you will need to use quotes.
Search WWH ::




Custom Search