my @tagList=('red','black'); my $ID = $dbh->selectall_arrayref("SELECT table FROM tags WHERE tag IN (join(', ', ('?') x @tagList))");