开发者

How to make this query?

开发者 https://www.devze.com 2023-03-25 22:42 出处:网络
I have two tables: Teams id name Games id date idlocal idvisitor idlocal and idvisitor 开发者_运维知识库are the id of the teams in the teams table.

I have two tables:

Teams

  • id
  • name

Games

  • id
  • date
  • idlocal
  • idvisitor

idlocal and idvisitor 开发者_运维知识库are the id of the teams in the teams table.

I need to make a SQL query that returns the date, the NAME of the first team, and the NAME of the second team, but I don't know how to do it.

Thanks


SELECT date,t1.name,t2.name FROM 
games g 
INNER JOIN teams t1 on t1.id=g.idlocal
INNER JOIN teams t2 on t2.id=g.idvisitor
0

精彩评论

暂无评论...
验证码 换一张
取 消