commit 4f5f5c6bfc964d9c136b0d3490ddaa6a53a4c25c Author: David G. Johnston Date: Wed Oct 21 23:23:33 2020 +0000 Some word-smithing to go along with my email comments diff --git a/doc/src/sgml/query.sgml b/doc/src/sgml/query.sgml index 413763691e..bc42381427 100644 --- a/doc/src/sgml/query.sgml +++ b/doc/src/sgml/query.sgml @@ -440,13 +440,12 @@ SELECT DISTINCT city Thus far, our queries have only accessed one table at a time. - Queries can access multiple tables at once, or access the same - table several times. Such queries — they are called - join queries — combine - rows of one table in some way with rows of the other table - and return a single row per combination. An example may be a - list of all the weather records together with the location of the - associated city. To do that, we need to compare the city + Queries which access multiple tables (including repeats) at once are called + join queries. They internally combine + each row from one table with each row of a second table. A expression is + specified to then limit which pairs of rows are returned. + For example, to return all the weather records together with the location of the + associated city, the database compare the city column of each row of the weather table with the name column of all rows in the cities table, and select the pairs of rows where these values match. @@ -466,8 +465,8 @@ JOIN cities ON (city = name); The keyword JOIN connects the two tables. - Behind the keyword ON follows the - definition how to compare their rows. In this case, the + After the keyword ON follows the + expression comparing their rows. In this case, the column city of table weather must be equal to the column name of table cities. @@ -483,14 +482,8 @@ JOIN cities ON (city = name); - Observe some things about the result set: + Observe two things about the result set: - - - The resulting rows contain values from both tables. - - - There is no result row for the city of Hayward. This is @@ -546,13 +539,15 @@ JOIN cities ON (cities.name = weather.city); SELECT * FROM weather, cities -WHERE weather.city = cities.name; +WHERE city = name; - This syntax is mainly used in legacy applications. It dates back - to the first days of SQL, avoids the JOIN - keyword, and uses the WHERE clause instead of the - ON clause. + This syntax pre-dates the JOIN and ON + keywords. The tables are simply listed in the FROM, + comma-separated, and the comparison expression added to the + WHERE clause. As join expressions serve a specific + purpose in a multi-table query it is preferable to make them stand-out + by using join clauses to introduce additional tables into the query. joinouter @@ -565,8 +560,8 @@ WHERE weather.city = cities.name; found we want some empty values to be substituted for the cities table's columns. This kind of query is called an outer join. (The - joins we have seen so far are inner joins.) The command looks - like this: + joins we have seen so far are inner joins.) + The command looks like this: SELECT *