Now what I wan to do is search through this table and comparing the service_id here to the service id of the next table. The next table comes from a query where all routes are selected with stops at a certain distance away from our route. What I need to be able to do is to find the matching service id of these two tables and then use a print statement to print the associated information:stop_reference | service_id | distance | route_number ----------------+------------+------------------+-------------- 8888888888 | 2 | 137.74251340817 | 2 1010101010 | 3 | 77.3369252039412 | 3
Now while I can find if the last two service id's on each table match i need to be able to loop through them all and compare every row produced by the queries. Note the number of rows will be much larger this is just an example to work with for simplicity.$connectsql = qq{SELECT b.service_id, d.stop_a, d.stop_b FROM bus_stop +s a, routes b, service c, topology d WHERE a.stop_reference = c.stop_ +reference AND c.service_id = b.service_id AND a.stop_reference = d.st +op_a ORDER BY a.stop_reference}; $sth = $dbh->prepare( $connectsql ); $sth->execute(); $sth->bind_columns( undef, \$connect_service, \$connect_stop, \$servic +e_stop ); while( $sth->fetch() ) { print..... } service_id | stop_a | stop_b ------------+------------+------------ 3 | 1010101010 | 8888888888 1 | 3333333333 | 6666666666 2 | 6666666666 | 3333333333 2 | 8888888888 | 1010101010
In reply to Re: Comparing two variables from different loops
by Anonymous Monk
in thread Comparing two variables from different loops
by Harch84
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |