kiat has asked for the wisdom of the Perl Monks concerning the following question:
I'm doing a LEFT JOIN of two tables. The tables contain something like:
$matrix_ref holds the output as follows:#table1 fruit_id fruit 1 apple 2 orange 3 pear #table2 some_id fruit_id some_col 1 1 a1 2 1 a2 3 1 a3 4 2 z1 5 2 z2 my $dbi = get_connection(); # sql my $sql = q~ SELECT fruit, some_col FROM table1 LEFT JOIN table2 ON table1.fruit_id=table2.fruit_id WHERE table1.fruit_id=1 ~; # Relevent Perl code my $sth = $dbh->prepare($sql); $sth->execute(); my $matrix_ref = $sth->fetchall_arrayref();
Somewhat duplicative. Is there a way to get the following output?[[apple, a1], [apple, a2], [apple, a3]];
As usual, thanks for reading and offering help :)[[apple, a1, a2, a3]];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DBI fetchall_arrayref
by amw1 (Friar) on Jun 15, 2004 at 15:39 UTC | |
by kiat (Vicar) on Jun 15, 2004 at 15:45 UTC | |
|
Re: DBI fetchall_arrayref
by Tomte (Priest) on Jun 15, 2004 at 15:45 UTC | |
|
Re: DBI fetchall_arrayref
by jeffa (Bishop) on Jun 15, 2004 at 17:40 UTC | |
|
Re: DBI fetchall_arrayref
by chance (Beadle) on Jun 15, 2004 at 15:38 UTC | |
|
Re: DBI fetchall_arrayref
by Roy Johnson (Monsignor) on Jun 15, 2004 at 15:52 UTC |