sql语句的问题,请求帮助!!

[复制链接]
查看11 | 回复2 | 2009-6-19 18:26:25 | 显示全部楼层 |阅读模式
1.mysql5.0
2.表名t_bus 列名bus_number(公交车车次) bus_station(站名)station_order(当前站站号)
3.需求:任意输入两个站名可以查询公交车的车次以及换乘站(只能换乘一次)
eg:1路公交车a-b-c-d-e-f-g
2路公交车:m-n-e-f-p-q输入:a, q
得到结果为 1路 2路 换乘e;1路 2路 换乘f
4.我写的sql语句,不知道问题何在,没有结果。
select a.bus_number, b.bus_number,a.bus_station
from (select * from t_bus where bus_station='a') as a join

(select * from t_bus where bus_station='d') as b
where a.bus_station =b.bus_station
5.希望大侠们给指点下,能给直接写个sql就更好了。谢谢各位。
gypt123 说的对, 谢谢你先。问题解决一起送分。
那我还是没想好应该怎么写.

回复

使用道具 举报

千问 | 2009-6-19 18:26:25 | 显示全部楼层
select a.BUS_NUMBER,b.BUS_NUMBER,a.BUS_STATION from (select * from t_bus where BUS_NUMBER in(select BUS_NUMBER from t_buswhere bus_station='a')) a,(select * from t_bus where BUS_NUMBER in(select BUS_NUMBER from t_buswhere bus_station='q')) bwhere a.BUS_STATION=b.BUS_STATION; 解释一下,(select * from t_bus where BUS_...
回复

使用道具 举报

千问 | 2009-6-19 18:26:25 | 显示全部楼层
select * from t_bus where bus_station='a'是什么?只能查出来过a站的公交车所有公交车车次并不能知道每一路公交车所经过全部的站是什么,怎么能计算出在哪换站呢 ?...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行