November 8, 2010 at 12:15 am
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 Stopno
1 1 A 1
2 1 B 2
3 1 C 3
4 1 D 4
5 1 E 5
6 2 A 5
7 2 B 4
8 2 C 3
9 2 D 2
10 2 E 1
November 8, 2010 at 12:19 am
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.
Never 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[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
November 8, 2010 at 12:19 am
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
November 8, 2010 at 12:31 am
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.
November 8, 2010 at 9:29 pm
Got it Thanks every 😎 :hehe: 😉 😛 😀 🙂
select distinct t1.*,T2.* from Table_1 t1 inner
join Table_1 t2 on t1.routeno=t2.routeno
where (t1.stop='A' ) and (t2.stop='E')
and t2.stopno>t1.stopno
order by t1.routeno
select distinct t1.*,T2.* from Table_1 t1 inner
join Table_1 t2 on t1.routeno=t2.routeno
where (t1.stop='D' ) and (t2.stop='E')
and t2.stopno>t1.stopno
order by t1.routeno
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply