SQL update multiple rows with different values, without specifying a single key


I need help building a SQL query which searches for an user_id (let's say user_id = 5), but this user_id has multiple row entries, but I need to update each row differently though.

I have an array with data which I want to assign to that user_id. Here is a table example:

id    user_id    amount    txn_id
1     5          10        foo_unique
2     5          5         bar_unique
3     7          15        xyz_unique
4     5          10        123_unique

My array would look something like this:

Array (
    [0] => 14
    [1] => 6
    [2] => 9

As you see I have three array values and three rows for user_id 5, now I want to add each value of that array, to the corresponding user_id (5). Note that I have an UNIQUE column named txn_id

After updating the table, it would look like this:

id    user_id    amount    txn_id
1     5          14        foo_unique
2     5          5         bar_unique
3     7          6         xyz_unique
4     5          9         123_unique

Any ideas how I could achieve this?


P.S: I cannot use SQL CASE on this issue.

If you want to update one row with a value, you have to be able to have a unique condition for that row.

Without adding some extra field, or condition to uniquely identify a row, you are out of luck.