Database Reference
In-Depth Information
If you want a heftier bird_family table with more rows and the brief descriptions, you
can download it later from my site. This is enough data for now. Let'sexecute the
SELECT statement to get the family_id numbers. We'll need them when we enter
birds in the birds table:
SELECT family_id, scientific_name
FROM bird_families
ORDER BY scientific_name;
+-----------+-----------------+
| family_id | scientific_name |
+-----------+-----------------+
| 109 | Accipitridae |
| 102 | Anatidae |
| 106 | Caprimulgidae |
| 103 | Charadriidae |
| 111 | Formicariidae |
| 100 | Gaviidae |
| 112 | Laniidae |
| 104 | Laridae |
| 108 | Picidae |
| 107 | Sittidae |
| 105 | Sternidae |
| 110 | Tyrannidae |
+-----------+-----------------+
I added an extra tweak to the previous SELECT statement: an ORDER BY clause, ensur-
ing that the results would be ordered alphabetically by the scientific name of the order.
We'll cover the ORDER BY clause in more depth in Chapter7 .
We're now ready to enter data in the birds table. The table already has a Killdeer, a
small shore bird that is part of the Charadriidae family. Let's prepare to enter a few more
shore birds from the same family as the Killdeer. Looking at the preceding results, we can
determine that the family_id is 103 , because the Killdeer is in the Charadriidae fam-
ily. Incidentally, the values for the family_id column might be different on your server.
Now that we have the family_id for shore birds, let's look at the columns in the
birds table and decide which ones we'll set. To do that, let's usethe SHOW COLUMNS
statement like this:
SHOW COLUMNS FROM birds;
+------------------------+--------------+------+-----+-------+----------------+
| Field | Type | Null | Key |Default|
Extra |
Search WWH ::




Custom Search