This is a contrived example using SQL Server 2008.
I'm essentially storing a list of ids in an xml column in a table: temp (bigint id, xml ids)
I want to join the table itself to the xml nodes.
So far I have:
select * from temp x
join (
select x.id
, ids.id.value('@value', 'bigint') zid
from temp t cross apply ids.nodes('/ids/id') as ids(id)
) z on x.id=z.id
I get: The multi-part identifier "x.id" could not be bound.
This just looks like a normal correlated subquery to me. What am I missing?
----- update:
For the following sample data in the temp table:
id ids
-- ---
1 <ids><id value="11" /><id value="12" /><id value="13" /></ids>
2 <ids><id value="21" /><id value="22" /><id value="23" /></ids>
3 <ids><id value="31" /><id value="32" /><id value="33" /></ids>
I would expect to see the following as the result set:
id zid
-- ---
1 11
1 12
1 13
2 21
2 22
2 23
3 31
3 32
3 33