Hmm... it looks to me that you should read up on database design and SQL. You can solve it like this in Perl, but I wouldn't. Oh and I would use DBD::ODBC instead, so your code would be a bit more portable.

I'd make several tables for business_unit, group, subgroup and application, referering to each other where appropriate. and a cross table between subgroup and application.

Then do something like:

my $result = $dbh->selectall_arrayref( "SELECT application.name FROM application, group, subgroup, app_sub +group WHERE application.id = app_subgroup.application AND app_subgroup.subgroup = subgroup.id AND subgroup.group = group.id AND group.name='Procurement'" ); foreach (@$result) { print @$_; }
With the current model it would look like:
my $result = $dbh->selectall_arrayref( "SELECT DISTINCT(application) FROM table_name WHERE group_name='Procurement'" ); foreach (@$result) { print @$_; }
Which is simpler, but will get you in trouble later on when your table starts getting bigger and bigger and people start spelling Internet Explorer as "Internt Explorer".


In reply to Re: Extracting data from an Ms ACCESS query by Joost
in thread Extracting data from an Ms ACCESS query by blackadder

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.