Hi Monks!

I have two big database tables that I "can not join", and I need to make a report out of it, and the only way I found based on how the real application works is to go first to the first table and than after finding all the "acc_num and dates" go to the second table, and after build my final report with the header values as you can see on this code sample.

# Start first sql... my $dbh = DBI->connect... my $sql = " SELECT acc_num, date, user1, user2, user3, user4, user5, user6, user7, FROM users_info WHERE date='2009-04-11' "; my $sth = $dbh->prepare($sql)|| die $dbh->errstr; $sth->execute() or die "$!\n"; my $array_ref = $sth->fetchall_arrayref(); my @ar_acc_num; foreach my $vals (@$array_ref){ my ($acc_num, $date, $all_users) =@$vals; push @ar_acc_num ,$pol_num; # I will need to push $date into an array as well, but one problem at +a time. } # here I have part of the data I need unshift @{ $array_ref }; # here I have all the acc numbers I need to go after on the second tab +le: # print "@ar_acc_num"; # Start second sql... my $dbh_b = DBI->connect... my $values = join("," ,map { $dbh_sec->quote($_) } @ar_acc_num ); my $sql_b = " SELECT add, acc, date, email, phone, city, state, country, reg FROM all_info WHERE date='2009' /* # it should be the value of $date pu +shed previously but for now I am using static year of 2009 */ AND acc IN ($values) "; my $sth_b = $dbh_b->prepare($sql_b)|| die $dbh_b->errstr; $sth_b->execute() or die "$!\n"; my $header = [ "Acc. Num", "Date", "User 1", "User 2", "User 3", "User 4", "User 5", "User 6", "User 7", "Add", "Acc", "Email", "Phone", "City", "State", "Country", "Regular", ]; my $array_ref_b = $sth_b->fetchall_arrayref(); #***Here I need to add @{ $array_ref } to @{ $array_ref_b } to contai +n all the data I need to format my report, that's where my problem is, how to do that? ## @{ $array_ref_b }= @{ $array_ref }.@{ $array_ref_b }; unshift @{ $array_ref_b }, $header;

What I am trying to do here is to add "@{ $array_ref } to @{ $array_ref_b }" to contain all the data I need to format my report, that's where my problem is, how to do that?
Thanks for the Help!!!!

In reply to Array_ref into Array_ref Help. 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.