Jump to content

Updating With Nested Select (complex)


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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...