I have the following table:
IDs ZoneID ChildID ParentID
--------------------------------------------
null 1 36000 36000
null 1 36000 36000
null 2 37000 37000
I want to update the IDs column with the following select statement:
SELECT a.ZONEID FROM Table1 a INNER JOIN Table1 b on a.ParentID = b.ChildID
So, the IDs column will be filled with the result of the select statement above.
The result should be:
IDs ZoneID ChildID ParentID
--------------------------------------------
1 1 36000 36000
1 1 36000 36000
2 2 37000 37000
I tried the following tsql:
Update Table1
set IDs = (SELECT a.ZONEID FROM Table1 a INNER JOIN Table1 b on a.ParentID = b.ChildID)
But error appears when I execute it. Too many argument result, something like that.
Please advice.
Thank you.