## how design query

 Author Message buntymanoj SSC Rookie Group: General Forum Members Points: 49 Visits: 12 hi all below i am showing my bus route table now how i can find out which route will come if i user want to go B to D stop (If user choose B to D stop then route no 1 will come)Id Route Stops Stopno1 1 A 12 1 B 23 1 C 34 1 D 45 1 E 56 2 A 57 2 B 48 2 C 39 2 D 210 2 E 1 Evil Kraig F SSC Guru Group: General Forum Members Points: 82489 Visits: 7660 Bunty, you left out too much of the question for us to even point you in the right direction, because if I read this right, you CAN go from B to D. If you're going to ask homework questions, at least do it properly, see the first link in my signature. - Craig FarrellNever stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake. For better assistance in answering your questions | Forum NetiquetteFor index/tuning help, follow these directions. |Tally TablesTwitter: @AnyWayDBA Henrico Bekker SSC-Insane Group: General Forum Members Points: 22384 Visits: 5465 post your query? -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------This thing is addressing problems that dont exist. Its solution-ism at its worst. We are dumbing down machines that are inherently superior. - Gilfoyle buntymanoj SSC Rookie Group: General Forum Members Points: 49 Visits: 12 select distinct t1.routeno from Table_1 t1 innerjoin Table_1 t2 on t2.stop=t1.stop where (t1.stop='D' and t1.stopnot2.stopno ) problem in this query is its showing me route no 2 also select distinct t1.routeno from Table_1 t1 innerjoin Table_1 t2 on t2.stop=t1.stop where (t1.stop='A' and t1.stopnot2.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) andRoute 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. buntymanoj SSC Rookie Group: General Forum Members Points: 49 Visits: 12 Got it Thanks every ;-) :-P :-D :-) select distinct t1.*,T2.* from Table_1 t1 innerjoin Table_1 t2 on t1.routeno=t2.routeno where (t1.stop='A' ) and (t2.stop='E')and t2.stopno>t1.stopnoorder by t1.routenoselect distinct t1.*,T2.* from Table_1 t1 innerjoin Table_1 t2 on t1.routeno=t2.routeno where (t1.stop='D' ) and (t2.stop='E')and t2.stopno>t1.stopnoorder by t1.routeno