表:TrainList(列车车次表)字段说明
ID(车次,Train表外键);Type(列车类型);startStation(始发站);endStation(终点站);R_Date(运行时间);Distance(里程 Int)
表:Train(列车时刻详细表)字段说明
ID(车次);Type(列车类型);Station(车站);S_No(站序 Int);Day(天数 Int);A_Time(到达时间);D_Time(开车时间);R_Date(运行时间);Distance(里程 Int);P1(硬座);P2(软座);P3(硬卧);P4(软卧)
表:Pinyin(站台名称-拼音-省市表)字段说明
ID(数字 Int);Station(车站);Shortcode(拼音缩写);FullCode(完整拼音);Province(省份/直辖市);ProPinyin(省份/直辖市 拼音);Call(备用,可用于计数 Int)
注:以上表字段除已标注数据类型外,其余均为 NVarChar 字符串类型
列车时刻表高级开发:中途车价格计算、中转站查询SQL 请点击这里
下载帮助。
-- 通过火车车次查询列车经由车站明细 SQL
/* 1 */
SELECT * FROM [Train] WHERE ([ID] LIKE @ID) ORDER BY [S_No] ASC
/* 2 */
SELECT Train.*, TrainList.startStation, TrainList.endStation FROM [TrainList] INNER JOIN
[Train] ON TrainList.ID = Train.ID WHERE (TrainList.ID LIKE @ID) ORDER BY Train.S_No ASC
-- 通过车站名称查询经过列车 SQL
SELECT TrainList.*, Train.A_Time, Train.D_Time
FROM [TrainList] INNER JOIN Train ON TrainList.ID = Train.ID
WHERE (Train.Station = @Station) ORDER BY TrainList.ID ASC
-- 通过发车站@sStation和到达站@eStation查询火车时刻表 SQL
/* DD 到达站, CF 出发站, DDSJ 到达时间, CFSJ 出发时间, DDLC 到达里程,
CFLC 出发里程, DDT 到达天数, CFT 出发天数 */
SELECT Train.[ID], Train.[Type], Train.Station AS DD, Train_1.Station AS CF,
Train.A_Time AS DDSJ, Train_1.D_Time AS CFSJ, Train.R_Date, Train.Distance AS DDLC,
Train_1.Distance AS CFLC, Train.P1, Train.P2, Train.P3, Train.P4,
TrainList.startStation, TrainList.endStation, Train.Day AS DDT, Train_1.Day AS CFT
FROM TrainList INNER JOIN (Train INNER JOIN Train AS Train_1 ON Train.ID = Train_1.ID)
ON (TrainList.ID = Train.ID) AND (TrainList.ID = Train_1.ID)
WHERE ((Train.Station LIKE @eStation) AND (Train_1.Station LIKE @sStation)
AND (Train_1.S_No < Train.S_No))
-- 通过拼音缩写查询车站名称 SQL
SELECT [Station] FROM [Pinyin] WHERE ([Shortcode] LIKE @Shortcode) ORDER BY [Station] ASC
-- 获得全部车站名称和拼音缩写 SQL
SELECT * FROM [Pinyin] ORDER BY [Shortcode] ASC
-- 获得火车时刻表全部车次 SQL
SELECT * FROM [TrainList] ORDER BY [ID] ASC
-- 通过拼音缩写查询火车时刻表(三表联查) SQL
SELECT Train.*, TrainList.R_Date, TrainList.Distance, TrainList.startStation,
TrainList.endStation, TrainList.Type
FROM Pinyin INNER JOIN (TrainList INNER JOIN Train ON TrainList.ID = Train.ID)
ON Pinyin.Station = Train.Station WHERE (((Pinyin.Shortcode) Like @Shortcode));