RE: Re: [PHP] update count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If you aren't using a unique key, you can always use "LIMIT 1" at the
end of your query, but unless your ORDERing correctly to get the exact
data row you want to update, this can have unexpected results.



Gary Every
Sr. UNIX Administrator
Ingram Entertainment Inc.
2 Ingram Blvd, La Vergne, TN 37089
"Pay It Forward!"

-----Original Message-----
From: Bob Lockie [mailto:bjlockie@xxxxxxxxx] 
Sent: Wednesday, June 16, 2004 9:21 AM
To: PHP-DB Mailing List
Subject:  Re: [PHP] update count

On 06/16/04 09:53 John Nichel spoke:
> Bob Lockie wrote:
> 
>> What is the best way to only do an update if it going to update only 
>> one row?
>> I want to protect my code so that it won't accidentally update more 
>> than one row.
>> I can do a select first but there must be an easier way. :-)
>>
> 
> UPDATE thisDB.thisTable SET thisTable.thisColumn = 'thisValue' WHERE 
> thisTable.uniqueColumn = 'someUniqueValue'

Ok, a primary key is unique, right?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux