I have the follow query:
SELECT `peers`.uid, `user`.userid FROM `peers`, `user` WHERE `user`.userid = `peers`.uid
the FF. is the result of the query
userid,uid
1,1
1,1
1,1
3,3
96,96
96,96
To update the result of that, I have the ff query setup:
UPDATE `user`
INNER JOIN (
SELECT `peers`.uid, `user`.userid FROM `peers`, `user` WHERE `user`.userid = `peers`.uid
) AS my_current_select ON `user`.userid = my_current_select.userid
SET `user`.credits = `user`.credits + 0.25
However, the update query update only 3 times, each plus once 0.25 credits into userID 1,3,96
This is not what I want. I want to uniquely add 0.25 credits into each row result of the query.
For example:
UID 1: UID1.credit = UID1.credit + 0.25 * 3
UID 3: UID3.credit = UID3.credit + 0.25 * 1
UID 3: UID96.credit = UID96.credit + 0.25 * 2
How can I achieve this result?
Perhaps change your inner query to:
to get:
And then in your master query do: