- 积分
- 40165
- 好友
- 记录
- 主题
- 帖子
- 听众
- 收听
|
发表于 2013-1-8 16:15:04
|
显示全部楼层
首先你的语句都不对吧
[code=sql] SELECT b1.title_sc AS origin ,b1.lineid ,b2.title_sc AS destination,b2.stoporder-b1.stoporder AS stopcount FROM gw_bus_stop b1 inner join
gw_bus_stop b2 on b1.lineid=b2.lineid AND b1.stoporder<b2.stoporder AND b1.title_sc='牛头角' AND b2.title_sc='利景'[/code]
b2 b1是同一个表b1.lineid=b2.lineid 其它条件应该都不会成立了吧比如 b1.title_sc='牛头角' AND b2.title_sc='利景'
title_sc这一个字段怎么会有两个值呢?
应该这样写吧
[code=sql]SELECT b1.title_sc AS origin ,b1.lineid ,b2.title_sc AS destination,b2.stoporder-b1.stoporder AS stopcount
FROM
gw_bus_stop b1 inner join
gw_bus_stop b2
on b1.lineid=b2.lineid
WHERE b1.stoporder<b2.stoporder AND b1.title_sc='牛头角' AND b2.title_sc='利景'[/code]
当然也可以这样写
[code=sql]SELECT b1.title_sc AS origin ,b1.lineid ,b2.title_sc AS destination,b2.stoporder-b1.stoporder AS stopcount
FROM
gw_bus_stop b1 ,
gw_bus_stop b2
WHERE b1.stoporder<b2.stoporder AND b1.title_sc='牛头角' AND b2.title_sc='利景'[/code]
|
|