0

Basically, I'm trying to do the same thing as the person asking this question but the first anwser by 'aF' uses FROM in a way I've never seen.

SELECT 
    t1.team_name as team1, 
    t2.team_name as team2, 
    t.team_1, t.team_2
FROM trades t
INNER JOIN teams t1 ON t1.id = t.team_1
INNER JOIN teams t2 ON t2.id = t.team_2;

I've never seen a FROM statement with two arguments after it and just a space between them, and it's making it difficult to understand the answer. What does it mean?

Community
  • 1
  • 1
jermerf
  • 41
  • 7

2 Answers2

2

It's a short form for FROM trades AS t. It's an alias, so you don't have to write the whole table name again and again. And of course to distinguish the tables when you join the same table twice.

fancyPants
  • 50,732
  • 33
  • 89
  • 96
1

Many SQL interpreters can use the syntax FROM table t instead of FROM table as t. They work exactly the same way.

As an aside, this works in SELECT statements, and in JOIN as well.

Fritz
  • 624
  • 1
  • 7
  • 14