Do the rows always correspond one-to-one, except in the case where data is missing from one or the other?

If so, a solution is straightforward. You'll find elements in the first hash but not the second as you iterate over it. If you delete elements from the second hash as you find them, anything left in the second hash will be items that weren't in the first hash.

If there can be a many-to-one correspondence between the two, you can pull the first array into a hash with selectall_hashref, find elements in the first but not the second while iterating over the first array, then iterate over the second array to search for items which aren't in the first.

You can also have the SQL server do most of the work for you by JOINing the tables in an appropriate way. For example, a SELECT ... FROM table1 LEFT JOIN table2 ... will return all elements of table1, where possible joining the data from table2, and where not replacing it with null. SELECT ... FROM table2 LEFT JOIN table1 WHERE ... AND table1.something IS NULL will return all items in table2 with no corresponding row in table1. Maybe a better SQL hacker than I would know one query to efficiently do the whole thing.


In reply to Re: Data Set Combination by sgifford
in thread Data Set Combination by Anonymous Monk

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.