# The first SQL query to get the state value
my $citydata = $dbh->exec_select( "select city,state from mytable where city = ?", $city ); # This one gets me all the values found for state my $statedata = join ' OR ', map { "state = $_->{ state}" } @$citydata; # Now $statedate gets this: “state = NH OR state = NY”. # I would like to add place holders and pass these values into the second query # To read like “state = ? OR state ?” my $codedata = $dbh->exec_select( "select code from othertable where (year=2014 and ($statedata)), $citydata->{state},$citydata->{state} );