MYSQL:如何获取变量值的某个值?

时间:2019-01-30 21:47:54

标签: mysql

我对复杂的查询有疑问。因此,任务如下:

With which connections can or could one fly from Düsseldorf (ICAO_Code : EDDF)  
to Rome (ICAO_Code: LIRA), whereby a travel time of 24 hours should not be 
exceeded,
you are allowed to change trains for a maximum of 1 hour and have a minimum 
transfer time of 1 hour?

表格如下:

**flightexecution** (FlightNo, DepartureDateAndTimeUTC, ICAO_Origin, 
ICAO_Destination, PlaneID, FlightDurationInMinutes)

**airport** (ICAO_Code, AirportName, Address,ID)

我当前的代码如下:

SELECT fe.ICAO_Code_Origin, 
    CASE
    WHEN fe.ICAO_Code_Origin = 'EDDF' AND fe.ICAO_Code_Destination = 'LIRA' 
    THEN 'DIREKTFLUG' 
    ELSE fe.ICAO_Code_Destination 
    AS via,
    CASE
    WHEN fe.ICAO_Code_Origin = 'EDDF' AND fe.ICAO_Code_Destination = 'LIRA'
    THEN 0
    ELSE DATEDIFF(min, , SELEC....

最后一个陈述是有问题的。我想说:“中间停留点的(DepartureDateAndTime)-(DepartureDateAndTime + FlightDurationInMinutes)之间的时差。

但是我如何告诉MYSQL我想要这个特定的ICAO_Origin?

1 个答案:

答案 0 :(得分:0)

查找SELECT syntax

SELECT FlightNo,...
FROM flightexecution fe
WHERE fe.ICAO_Code_Origin = 'EDDF'
  AND fe.ICAO_Code_Destination = 'LIRA'
  AND FlightDurationInMinutes < 24*60;

提供的火车信息不足,无法回答这种情况。