Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Lets say you were performing an sql update statement which was supposed to update one row in table A with details from exactly one row from table B because these 2 tables were supposed to have a common field and one row in table A will have the same value for this field as exactly one row in table B. The query would be like this:
The query might be something likeupdate table A, table B set A.field1 = B.field1 where A.field2 = b.fie +ld2
But what would happen if a row in table A actually matched 2 or more rows in table B? Lets say row 5 in table A matched rows 20 and 30 in table B. I am thinking row A will get updated with the value from table B row 20 and then will get updated again with the value from row 30 in table B, this overwriting the previous update
I am trying to simulate this as we speak. But my perl question is what would be the 'number of rows affected' returned by the do method
Would it be the number of updates carried out even if the same row in table A was updated multiple times or would it just be one update as only one row in table A is ever updated? many thanks$rows_affected = $dbh->do($querystr);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: rows affected by an update command
by erix (Prior) on Nov 02, 2010 at 15:37 UTC | |
|
Re: rows affected by an update command
by JavaFan (Canon) on Nov 02, 2010 at 15:14 UTC | |
by Anonymous Monk on Nov 02, 2010 at 15:18 UTC | |
by kcott (Archbishop) on Nov 02, 2010 at 15:21 UTC | |
by afoken (Chancellor) on Nov 02, 2010 at 18:49 UTC | |
by Tux (Canon) on Nov 03, 2010 at 14:32 UTC | |
by JavaFan (Canon) on Nov 02, 2010 at 21:37 UTC | |
by ambrus (Abbot) on Nov 03, 2010 at 14:11 UTC | |
|
Re: rows affected by an update command
by aquarium (Curate) on Nov 02, 2010 at 23:53 UTC |