#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();
####
[[apple, a1], [apple, a2], [apple, a3]];
####
[[apple, a1, a2, a3]];