Train Direct Route Query
I'd suggest you another approach:




create table TrainStations
(
    RouteId int, 
    OrderId int, 
    StartStation varchar(50), 
    EndStation varchar(50)
);



By adding Route and Order (Stops), you can get the whole journey of no matter what route.




    SELECT RouteId,
           OrderId,
           StartStation, 
           EndStation
      FROM TrainStations
     WHERE RouteId = 3
  ORDER BY RouteId, OrderId;



ROUTEID | ORDERID | STARTSTATION  | ENDSTATION   
------: | ------: | :------------ | :------------
      3 |       1 | SF            | Palo alto    
      3 |       2 | Palo alto     | Mountain View
      3 |       3 | Mountain View | SF           



dbfiddle here

Or if you want a single line:




    SELECT CONCAT(CONCAT (t1.StartStation, ', '), 
                  (SELECT LISTAGG(t2.EndStation, ', ') WITHIN GROUP (ORDER BY t2.OrderId)
                   FROM TrainStations t2
                   WHERE t2.RouteId = t1.RouteId)) Route
    FROM   TrainStations t1
    WHERE  t1.RouteId = 3
    AND    t1.OrderID = 1;



| ROUTE                            |
| :------------------------------- |
| SF, Palo alto, Mountain View, SF |



dbfiddle here