Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re^2: Comparing two variables from different loops

by Eimi Metamorphoumai (Deacon)
on Jul 05, 2007 at 14:44 UTC ( #625051=note: print w/replies, xml ) Need Help??

in reply to Re: Comparing two variables from different loops
in thread Comparing two variables from different loops

Many others have suggested hashes, and that's definitely a valid approach. I'm curious, though, whether you couldn't achieve the same thing in SQL. That is, maybe you should just create a single query JOINing the two queries on service_id. That might reduce the amount of data you need to pull into Perl, and let the SQL server do the heavy lifting for you (which is what it's good at, after all).

Replies are listed 'Best First'.
Re^3: Comparing two variables from different loops
by atemon (Chaplain) on Jul 06, 2007 at 10:22 UTC

    Please try the SQL given below. This SQL is NOT tested, but should return records with origin_service == destination_service. Please refer to Subqueries with ANY, IN, and SOME

    SELECT a.stop_reference, b.service_id, distance(PointFromText('POINT($origin)', 27700),east_north), c.route_number FROM bus_stops a, service b, routes c WHERE distance(PointFromText('POINT($origin)', 27700),east_north) < 200 AND a.stop_reference = b.stop_reference AND b.service_id = c.service_id AND b.service_id IN ( SELECT DISTINCT e.service_id FROM bus_stops d, service e, routes f WHERE distance(PointFromText('POINT($dest)', 27700),east_north) +< 200 AND d.stop_reference = e.stop_reference AND e.service_id = f.service_id ORDER BY e.service_id, distance(PointFromText('POINT($dest)', 27700),east_north) ) ORDER BY b.service_id, distance(PointFromText('POINT($origin)', 27700),east_north)


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://625051]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (1)
As of 2020-10-24 17:13 GMT
Find Nodes?
    Voting Booth?
    My favourite web site is:

    Results (246 votes). Check out past polls.