ylbtech-dbs:12306-票

 

A,数据库关系图(Database Diagram) 返回顶部

 

B,数据库设计脚本(Database Design Script)返回顶部

3,查询余票

2,查询车次

--1/2,出发站和目的站在同一次列车时间表上
--2/2,起始站序<目的站序

2.2,

--2,查询车次,假设:菏泽-->曹县
--菏泽-->曹县
select tn.trainNumberCode,tn.trainNumberType
,tn.departureStationId,(select Station from Station where stationId=tn.departureStationId)'departureStation'
,tn.destinationStationId,(select Station from Station where stationId=tn.destinationStationId)'destinationStation'
,tn.departureTime,tn.destinationTime from TrainNumber tn 
where tn.trainNumberId in(
select t.trainNumberId from Timetable t
inner join Timetable t2 on t.trainNumberId=t2.trainNumberId
where t.sortCode<t2.sortCode
and t.stationId=(select stationId from Station where station='菏泽')
and t2.stationId=(select stationId from Station where station='曹县'))
View Code

相关文章: