my $sth = $dbh->prepare(' SELECT characters.first, characters.last FROM characters INNER JOIN people_characters ON characters.id = people_characters.characters INNER JOIN people ON people_characters.people = people.id WHERE people.first = ? AND people.last = ? ORDER by characters.last, characters.first '); $sth->execute(qw(John Smith)); while (my $row = $sth->fetchrow_hashref) { print "$row->{first} $row->{last}\n"; }