In MySQL, how can I use use union with two update statements, or run two update statements simultaneously, so I get the count of affected rows of both (together)?
I'm trying to run the two of them together, instead of having two separate ones. The two of them update two different rows, so they cannot be run together in a single statement. Any help?
Example:
update prodb set buyer = buyer+1 where userId = 1
union
update prodb set seller = seller+1 where userId = 2;
Update: Did it this way, but it still returns affected rows as one. I guess it's returning the number of rows from the second statement only.
$stmt = '
update prodb set buyer = buyer+1 where userId = 1;
update prodb set seller = seller+1 where userId = 2;
';
$update = $dbc->prepare($stmt);
$update->execute();