Let's look at each portion of the query:

  • SELECT quote,last

    SELECT quote,last FROM quote,name WHERE quote.name_id=name.id ORDER BY last;

    This part looks the same as in previous queries, except the quote and last fields being queried are in different tables.

  • FROM quote,name

    SELECT quote,last FROM quote,name WHERE quote.name_id=name.id ORDER BY last;

    quote and name are the two tables you're using in the query. The field quote is in the quote table; the field last is in the name table.

  • WHERE quote.name_id=name.id

    SELECT quote,last FROM quote,name WHERE quote.name_id=name.id ORDER BY last;

    The WHERE criterion links the quote and name tables together. This string tells the database that the name_id of a record in the quote table corresponds to a record with the same id in the name table.

    For instance, the president whose id is 1 delivered all quotes with an name_id of 1; the president whose id is 2 delivered quotes with name_id of 2, and so on.

  • ORDER BY last

    SELECT quote,last FROM quote,name WHERE quote.name_id=name.id ORDER BY last;

    This puts the list in alphabetical order by the presidents' last names.

Want ad-free tutorials like these for classroom use? Get them at Visilearn.com.