SQL-Tutorial icon indicating copy to clipboard operation
SQL-Tutorial copied to clipboard

Bug in part 3 self-joins

Open SmearingMap opened this issue 9 years ago • 1 comments

In part 3 of the SQLite tutorial, the first command in the self-joins section is broken. Instead, it should be:

SELECT a.last_name, a.first_name, a.amount, b.amount FROM contributors a, contributors b WHERE a.last_name = b.last_name AND a.first_name = b.first_name;

Currently, it is:

SELECT a.last_name, a.first_name, a.amount, b.amount FROM a, b WHERE a.last_name = b.last_name AND a.first_name = b.first_name;

which leaves a and b undefined and results in an error.

PS I love the tutorial! I've found it very helpful.

SmearingMap avatar May 03 '15 21:05 SmearingMap

Hi Mike,

Thanks for this feedback.

The first example in that section is supposed to refer to a situation where the data lives in two separate tables. I updated the text and example to try to make that clearer.

The idea was to introduce the concept of a self join by starting with a join using aliases on two tables. Then we can apply the same concept (joining two aliases for tables) when the two aliases both refer to the same table.

I'll leave this open, in case the changes still haven't made things clear.

tthibo avatar May 11 '15 17:05 tthibo