Re: update count

From: Date: Wed, 16 Jun 2004 14:10:20 +0000
Subject: Re: update count
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-188397@lists.php.net to get a copy of this message
On Wed, 16 Jun 2004 09:40:52 -0400, Bob Lockie <bjlockie@lockie.ca> wrote: > > What is the best way to only do an update if it going to update only one > row? You don't say what database you're using. The general way is to use a unique key in the WHERE clause. UPDATE tablename SET foo=1 WHERE id=123 MySQL also lets you use a LIMIT clause that will either limit the number of rows affected by the update, or matched by the WHERE clause depending on the MySQL version. UPDATE tablename SET foo=1 WHERE bar=2 LIMIT 1 -robin

« previous php.general (#188397) next »