SQL nested query (not exists) -


i have table called train, has columns number, arrive_station, depart_station

i have populated , find trains serve edinburgh (i.e., trains departing station arrive edinburgh) use nested query , use not exists operator.

so far have tried..

select depart_station train arrive_station = "edinburgh"    , not exists   (     select arrive_station     train     arrive_station != "edinburgh"   ); 

you need relate nested query outer query somehow if number train number you'd want add aliases tables , add and t1.number = t2.number.

select  depart_station    train t1   arrive_station = "edinburgh"  ,     not exists         (             select  arrive_station                train t2               t2.arrive_station != "edinburgh"             ,     t1.number = t2.number         ); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -