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 说的对, 谢谢你先。问题解决一起送分。
那我还是没想好应该怎么写.
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_...