$EMAIL1 = $q->param('Email1'); $EMAIL2 = $q->param('Email2'); $EMAIL3 = $q->param('Email3'); $sth = $dbh->prepare("select user from table1 where user = '$EMAIL1' or user = '$EMAIL2' or user = '$EMAIL3'"); $rc = $sth->execute(); while (my $row = $sth->fetchrow_hashref) { $GID = $$row{gid}; $USER = $$row{user}; }