首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

小弟 跪求高手!如何将两个sql语句和一起 既查出起始-中转-到达城市的信息也查出起始-到达城市的信息

2012-03-31 
小弟 跪求高手!怎么将两个sql语句和一起 既查出起始-中转-到达城市的信息也查出起始-到达城市的信息//查的

小弟 跪求高手!怎么将两个sql语句和一起 既查出起始-中转-到达城市的信息也查出起始-到达城市的信息
//查的是起始-中转-到达城市的信息
select c1.*, a1.area as StartCity, a2.area as MidCity, a3.area as EndCity from `customer` as c1, `area` as a1, `area` as a2, `area` as a3 where c1.StartCity = a1.value and c1.EndCity = a3.value and c1.MidCity = a2.value

//查的是起始-到达城市的信息
select c1.*, a1.area as StartCity, a2.area as MidCity, a3.area as EndCity from `customer` as c1, `area` as a1, `area` as a2, `area` as a3 where c1.StartCity = a1.value and c1.EndCity = a3.value and c1.MidCity = a2.value

请问 怎么将两个sql语句和一起 既查出起始-中转-到达城市的信息也查出起始-到达城市的信息



[解决办法]

SQL code
select c1.*, a1.area as StartCity, a2.area as MidCity, a3.area as EndCity from `customer` as c1, `area` as a1, `area` as a2, `area` as a3 where c1.StartCity = a1.value and c1.EndCity = a3.value and c1.MidCity = a2.valueunion allselect c1.*, a1.area as StartCity, a2.area as MidCity, a3.area as EndCity from `customer` as c1, `area` as a1, `area` as a2, `area` as a3 where c1.StartCity = a1.value and c1.EndCity = a3.value and c1.MidCity = a2.value 

热点排行