日期:2014-05-17  浏览次数:20476 次

sql高级查询问题
有表1Air,字段:id,fromCityId,toCityId,price,dateTimes 表2City,字段:id,cityName 
怎样查出:编号、出发城市、到达城市、价格、时间?????

------解决方案--------------------
看不懂你想表达什么
怎样查出:编号、出发城市、到达城市、价格、时间? select * from 1Air不就行了
------解决方案--------------------
SQL code

select a.*,c1.cityname as 出发城市,c2.cityname as 到达城市 from air a left join city c1 on c1.id = a.fromCityId left join city c2 on c2.id = a.toCityID

------解决方案--------------------
SQL code

SELECT A.id, C1.cityName fromCityName, C2.cityName toCityName, A.price, A.dateTimes
FROM Air A
JOIN City C1
ON A.fromCityId=C1.id
JOIN City C2
ON A.toCityId=C2.id