my $sql = 'SELECT user_id, user_name FROM users WHERE user_id IN (' . join(',', ('?') x @ids) . ')'; #... $sth->execute(@ids);