I have a query which returns
Primary Key | Value
And I want to update my data where primary key = primary key and value = another value. So basically I have
SELECT
id,
custom_value
FROM custom
JOIN user
USING (user_id)
WHERE id = 45
AND custom_name = "stuff";
And this generates
id | custom_value
1 | stuff
2 | stuff 2
And I want to then UPDATE the existing db with
UPDATE table SET field = custom_value WHERE id = id;
Or if I used the first row it would be
UPDATE table SET field = 'stuff' WHERE id = 1;
How could I do this?
So...
SELECT UPDATE table
id, -> WHERE id = id
custom_value -> SET field = custom_value
FROM custom
JOIN user
USING (user_id)
WHERE id = 45
AND custom_name = "stuff";
Select data then update another table with that data.