On Fri, Aug 03, 2001 at 10:26:20PM -0500, Mike Blezien wrote:
> 
> >>On Fri, 3 Aug 2001 22:22:57 -0500, Paul DuBois <[EMAIL PROTECTED]>   wrote:
> 
> >>$selquery = qq|SELECT memid FROM optin WHERE time > NOW()|;
> >>$sth = $dbh->prepare($selquery);
> >>$delquery = qq|DELETE FROM members WHERE memid > ?|;
> >>$delsty = $dbh->prepare($delquery);
> >>while ($ids = $sth->fetchrow_hashref()) {
> >>       $delsth->execute($ids->{'memid'});
> >>    }
> 
> Yes, exactly! After I looked at the code again, I notice that this wouldn't
> work! And re-wrote exactly like you have it. :)
> 
> But my question is, is it OK to do a mass deletion like this? Can it cause
> problems?

I don't think it will have problems, but conceptually it doesn't make
sense.  You're doing numerous deletes 'WHERE memid > ?', but you really
only need to do one delete with the minimum memid.


$selquery = qq|SELECT MIN(memid) FROM optin WHERE time > NOW()|;
$delquery = qq|DELETE FROM members WHERE memid > ?|;
$delsth = $dbh->prepare($delquery);
($memid) = $dbh->selectrow_array($selquery);
$delsth->execute($memid);


Ronald



Reply via email to