OK as requested here is some more information and a small example of the data I am looking to compare with. An example of the output of the first SQL queries I have given is this:
stop_reference | service_id | distance | route_number ----------------+------------+------------------+-------------- 8888888888 | 2 | 137.74251340817 | 2 1010101010 | 3 | 77.3369252039412 | 3
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:
$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
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.

In reply to Re: Comparing two variables from different loops by Anonymous Monk
in thread Comparing two variables from different loops by Harch84

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.