$sth = $dbh->prepare("SELECT year from trees WHERE sport = \'$sport\' AND year = + \'$year\'") || die "couldn't prepareSQL statement"; $sth->execute || die "can't execute sql statement"; my @row; while (@row = $sth->fetchrow_array()) { $year = $row[0]; }