![SQL - update of a new column in the table - adding a value from another column (subquery update)](/assets/img/pages/types/23.jpg)
SQL - update of a new column in the table - adding a value from another column (subquery update)
Hi,
I added a new uuid column to the uploads table and I need to copy the ID value to each row. How to do it? I guess it will be using subquery. Thanks
Hi,
You can update records using SQL subquery as follows:
I added a new uuid column to the uploads table and I need to copy the ID value to each row. How to do it? I guess it will be using subquery. Thanks
REPLY
Hi,
You can update records using SQL subquery as follows:
UPDATE uploads target SET uuid = (
SELECT src.id FROM uploads src
WHERE src.id = target.id
)