When UPDATE doesn't work..

This is a discussion on When UPDATE doesn't work.. within the MySQL Database forums, part of the Database Forums category; eg UPDATE MyTable SET SomeField = 20 WHERE AnotherField = -1 If the table MyTable has no record with AnotherField = -1, obviously ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 09-15-2006
Occidental
 
Posts: n/a
Default When UPDATE doesn't work..

eg

UPDATE MyTable SET SomeField = 20 WHERE AnotherField = -1

If the table MyTable has no record with AnotherField = -1, obviously no
update will take place, and the query will end normally. Is there any
way to capture the fact that no update has taken place (other than the
obvious trick of determining prior to the update whether AnotherField =
-1 exists)?

Reply With Quote
  #2 (permalink)  
Old 09-15-2006
Jerry Stuckle
 
Posts: n/a
Default Re: When UPDATE doesn't work..

Occidental wrote:
> eg
>
> UPDATE MyTable SET SomeField = 20 WHERE AnotherField = -1
>
> If the table MyTable has no record with AnotherField = -1, obviously no
> update will take place, and the query will end normally. Is there any
> way to capture the fact that no update has taken place (other than the
> obvious trick of determining prior to the update whether AnotherField =
> -1 exists)?
>


Depending on the language you're using, you can get the affected rows.
For instance, in PHP it's mysql_affected_rows().

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Reply With Quote
  #3 (permalink)  
Old 09-16-2006
Lee Peedin
 
Posts: n/a
Default Re: When UPDATE doesn't work..

On Fri, 15 Sep 2006 18:22:14 -0400, Jerry Stuckle
<jstucklex@attglobal.net> wrote:

>Occidental wrote:
>> eg
>>
>> UPDATE MyTable SET SomeField = 20 WHERE AnotherField = -1
>>
>> If the table MyTable has no record with AnotherField = -1, obviously no
>> update will take place, and the query will end normally. Is there any
>> way to capture the fact that no update has taken place (other than the
>> obvious trick of determining prior to the update whether AnotherField =
>> -1 exists)?
>>

>
>Depending on the language you're using, you can get the affected rows.
>For instance, in PHP it's mysql_affected_rows().


In Rexx, it's sqlca.rowcount

Lee
Reply With Quote
  #4 (permalink)  
Old 09-16-2006
Dikkie Dik
 
Posts: n/a
Default Re: When UPDATE doesn't work..

>> eg
>> UPDATE MyTable SET SomeField = 20 WHERE AnotherField = -1
>>
>> If the table MyTable has no record with AnotherField = -1, obviously no
>> update will take place, and the query will end normally. Is there any
>> way to capture the fact that no update has taken place (other than the
>> obvious trick of determining prior to the update whether AnotherField =
>> -1 exists)?

>
> Depending on the language you're using, you can get the affected rows.
> For instance, in PHP it's mysql_affected_rows().


Beware though, that the rows where SomeField was already 20 do not count
as "affected".

Best regards
Reply With Quote
  #5 (permalink)  
Old 02-22-2007
Norman Peelman
 
Posts: n/a
Default Re: When UPDATE doesn't work..

Dikkie Dik wrote:
>>> eg
>>> UPDATE MyTable SET SomeField = 20 WHERE AnotherField = -1
>>>
>>> If the table MyTable has no record with AnotherField = -1, obviously no
>>> update will take place, and the query will end normally. Is there any
>>> way to capture the fact that no update has taken place (other than the
>>> obvious trick of determining prior to the update whether AnotherField =
>>> -1 exists)?

>>
>> Depending on the language you're using, you can get the affected rows.
>> For instance, in PHP it's mysql_affected_rows().

>
> Beware though, that the rows where SomeField was already 20 do not count
> as "affected".
>
> Best regards


Well, they don't have anything to do with the query to begin with.

Norm
Reply With Quote
  #6 (permalink)  
Old 02-22-2007
Captain Paralytic
 
Posts: n/a
Default Re: When UPDATE doesn't work..

On 22 Feb, 10:58, Norman Peelman <npeel...@cfl.rr.com> wrote:
>
> Well, they don't have anything to do with the query to begin with.


Why don't they?

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:43 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0