my $struct = $sth->fetchall_hashref('extracted_ads_id'); # $struct will look like { foo => { extracted_ads_id => foo, prop_street_no => 12, prop_street_name => 'blah' } bar => { extracted_ads_id => bar, ..... } # access like $struct->{foo}->{prop_street_no} #### my $h; while ( my $row = $sth->fetchrow_arrayref() ) { $h->{$row->[0]} = [ @row[1,2] ]; } # $h will look like { foo => [ 12, blah ], bar => [ .... } # access like $h->{foo}->[0] will give you street no.