English subtitles

← Find the Fish Eaters - Intro to Relational Databases

Get Embed Code
4 Languages

Showing Revision 3 created 05/24/2016 by Udacity Robot.

  1. Holy wow, that's a lot of fish.
  2. Fortunately, we've got a lot
    of animals that eat fish.
  3. We talked about that
    briefly in lesson one, but
  4. now we can put together
    an actual query to find them.
  5. See if we can put it together
    without looking back there.
  6. Trouble is, the animals table tells
    us nothing about what each individual
  7. animal eats, and the diet table
    doesn't list any individual animals.
  8. It only lists their species.
  9. Wait a minute though.
  10. That species column is
    in both of those tables.
  11. That means it must be join time.
  12. So, if we join animals against diet,
  13. we should be to get the answer
    that we're looking for.
  14. Now, we saw one syntax for
    joins in lesson one, but
  15. it turns out there's also
    a shortcut syntax we can use here.
  16. The shortcut syntax won't actually use
    the word join when it lists the joined
  17. tables, but this form is actually
    probably more common in real code.
  18. If we want to join two tables to match
    up rows where the column target in
  19. table T equals the column match in
    table S, we can do it like this.
  20. So on the next page,
    write a query to answer this problem.
  21. You can use either kind of join,
    but your query should only
  22. return the name column,
    not the species or the word fish itself.