1

There is a TABLE name is team, total 1 column 'name' with 4 records ('a', 'b', 'c', 'd') representing four football teams.

Requires: Using one SQL syntax to show all the possible combinations of tow team.

I just learned about self_join so i used this:

SELECT a.name, b.name
FROM team AS a
INNER JOIN team AS b
WHERE a.name < b.name;

The question is: I saw the SQL SYNTAX which works out pretty good, but i can't figure out how it works. Anyone could help? thx.

This SQL SYNTAX is below:

SELECT a.name, b.name
from team a, team b 
where a.name < b.name;
coder
  • 7,778
  • 15
  • 37
  • 52
Sean.H
  • 462
  • 5
  • 16
  • `SELECT * FROM A, B ... WHERE ` is *synonym* for `SELECT * FROM A JOIN B ON ()` ;) – xerx593 May 05 '18 at 09:00
  • You saw archaic SQL syntax -- as if you were reading Shakespeare and started to talk like his characters because you saw the words written down. Joins are correctly written using standard, explicit, proper `JOIN` syntax, not with commas in the `FROM` clause. – Gordon Linoff May 05 '18 at 10:41

1 Answers1

1

These queries are just different ways to write the same thing. The first is ANSI-89 join syntax, the second ANSI-92 join syntax. The newer syntax is preferred because it keeps join conditions closer to the joined table, especially for multiple joins.

Andomar
  • 225,110
  • 44
  • 364
  • 390