你的位置:首页 > 数据库

[数据库]一个表中的两列与另一个表的一列关联的结果显示


station表

列名:

stationId-----站点编号

stationlon----站点经度

stationlat----站点纬度

record表

列名:

recorkId---------记录编号

stationGoId------借出站点编号

stationBackId----归还站点编号

查询结果显示列:

stationGoId-----借出站点编号

GoStationlon----借出站点经度

GoStationlat----借出站点纬度

stationBackId---归还站点编号

BackStationlon--归还站点经度

BackStationlat---归还站点纬度

1 select r.stationGoId,s1.stationlon as GoStationlon,s1.stationlat as GoStationlat,2 r.stationBackId,s2.stationlon as BackStationlon,s2.stationlat as BackStationlat3 from record as r,station as s1,station as s24 where r.stationGoId = s1.stationId and r.stationBackId = s2.stationId

sql查询结果: