I am trying to update the orgaization_id in location table which is primary key in Organization table.
update location set organization_id=org.old_id from organization as org
where location.old_id=org.old_id;
Facing syntax error please help..
You can use join to perform update from another table
update location l
join organization as o
on l.old_id=o.old_id
set l.organization_id=o.old_id;
请尝试以下代码:
update location set organization_id=(select old_id from organization where organization.old_id=location.old_id);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.