in reply to DBI fetchall_arrayref

If you only want to find the rows that match apple, then just fetch the rows for apples:

#untested my $matrix_ref = $dbh->selectall_arrayref(' SELECT some_col FROM table1 INNER JOIN table2 ON table1.fruit_id = table2.fruit_id WHERE table1.fruit = ? ', undef, 'apple');
This will yield:
[ [a1], [a2], [a3] ]
You can instead use selectcol_arrayref to return [a1, a2, a3].

No apple, but we already know we want apples.

[Updated, had to confirm exact return structure of a one column set from selectall_arrayref()]

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)