• select distinct t1.routeno from Table_1 t1 inner

    join Table_1 t2 on t2.stop=t1.stop

    where

    (t1.stop='D' and t1.stopno<t2.stopno)

    or(t1.stop='E' and t1.stopno>t2.stopno )

    problem in this query is its showing me route no 2 also

    select distinct t1.routeno from Table_1 t1 inner

    join Table_1 t2 on t2.stop=t1.stop

    where

    (t1.stop='A' and t1.stopno<t2.stopno)

    or(t1.stop='E' and t1.stopno>t2.stopno )

    This Query running fine

    there is to route (route no 1 and route no 2 )

    Route no 1 Bus going (A stop to E Stop) and

    Route no 2 Bus going (E stop to A Stop)

    If user want to go stop A to E or D to E then route no 1 will come. but i am not avail to find out how i design my query.