[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql
Subject:    mysql: Update problem
From:       Michael Widenius <monty () monty ! pp ! sci ! fi>
Date:       1999-01-31 0:08:43
[Download RAW message or body]

>>>>> "Mark" == Mark Papadakis <markp@forthnet.gr> writes:

Mark> Hi!
Mark> For the past 5 hours I 've been trying to figure out whats wrong my code
Mark> till I found
Mark> there is something wrong with mysql_affected_rows()..

Mark> query:
Mark> update cp set items=items+1 where uid=5 and pid=10;


Mark> When it should return (0) for no affected rows it returns 16! actually,
Mark> sometimes it even returns 16 even 
Mark> there are is 1 affected row.. It works fine with 3.22.29 but not with
Mark> 3.22.32 I now use..

Mark> Please check it out..
Mark> Mark

Hi!

3.21.32 ???

Please read the BUGS section in the MySQL manual.  If you have a key

that contains 'uid or pid' together with 'item', like '(id,item) then
you have been bit by it (sorry about that, but I need code from the
upcoming sub select library to fix this properly)

Fix in this case:

update cp set items=items+1 where uid+0=5 and pid+0=10;

(This will force MySQL to ignore keys when selecting rows to be updated)

Regards,
Monty
-----------------------------------------------------------
Send a mail to mdomo@tcx.se with
unsubscribe mysql your@subscription.address
in the body of the message to unsubscribe from this list.

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic