my $sth = $dbh->prepare("SELECT something FROM something_else WHERE col1 = ? OR col2 = ?"); $sth->execute($value1,$value2); while (my ($result) = $sth->fetchrow) { # do something with $result }