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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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)? |
|
|||
|
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 ================== |
|
|||
|
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 |
|
|||
|
>> 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 |
|
|||
|
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 |