Jump to content

Updating With Nested Select (complex)


geomagnet

Recommended Posts

Hello,I'm not sure how this is done. I want to update a table with values from another record.I tried this code but it doesn't work.

update task set link_id = (select link_id from task where task_id=1867) where task_id = (select task_id from task where link_id = 1867)

basically, my goal is to find tasks which are linked to other tasks via link_id which are going to be deleted.task_id link_id1863 Null1864 18621865 18621866 18651867 18661868 18671869 1866So, I plan to delete task_id 1867 but task_id 1868 is linked to it. So I need to link it to the parent of 1867 which is 1866. Thisway the records (when cascaded on output) will still work. After the update and delete it should look like this...1863 Null1864 18621865 18621866 18651868 18661869 1866Thanks---------------------- Ignore post ------ Solution found ---------------update task as a, task as bset a.link_id = b.link_idwhere b.task_id = a.link_idand a.link_id = 1867This works perfectly.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...