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;
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.