my @userids = ('XD4555', 'JJKKKK'); my $sth = $dbh->prepare("SELECT snd.EMAIL FROM FUSERS as m JOIN USERS as snd ON snd.USERID = m.USERID WHERE m.USERID_IM IN (?)"); $sth->execute(\@userids); my $mails = $sth->fetchall_arrayref();