欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

sql语句:同一张表两个相同外键查询实例分享

程序员文章站 2022-07-05 23:03:05
假设A表名称:City,B表名称:GoTo select a.CityName as '出发地', b.CityName as '目的地',...

假设A表名称:City,B表名称:GoTo

select a.CityName as '出发地', b.CityName as '目的地', c.LeaveDate as '出发时间'
from City as a, City as b, Goto as c
where c.FromCity = a.CityID
and c.ToCity = b.CityID

笔记