You may use OR operator, Kindly note the positions of paranthesis.
SELECT SUM(dist)FROM distance dd, tripleg t
WHERE
( (t.origin=dd.destination AND t.destination = dd.origin) or (t.origin=d.origin AND t.destination = d.destination) )
AND t#=1;
My query may cause you problem if there are two enteries for same route, I mean
Adelaide , Melbourne, 400
Melbourne , Adelaide , 400
I hope your table do not have such duplicate values
urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270