Thanks guys. So I'm left with
Code:
SELECT Location.sys_whr_id AS Level1, Location_1.sys_whr_id AS Level2, Location_2.sys_whr_id AS Level3, Location_3.sys_whr_id AS Level4,
Location_4.sys_whr_id AS Level5, Location_5.sys_whr_id AS Level6, Location_6.sys_whr_id AS Level7, Location_7.sys_whr_id AS Level8,
Location_8.sys_whr_id AS Level9, Location_9.sys_whr_id AS Level10
FROM Location LEFT OUTER JOIN
Location AS Location_1 ON Location.sys_whr_id = Location_1.sys_parent_id LEFT OUTER JOIN
Location AS Location_2 ON Location_1.sys_whr_id = Location_2.sys_parent_id LEFT OUTER JOIN
Location AS Location_3 ON Location_2.sys_whr_id = Location_3.sys_parent_id LEFT OUTER JOIN
Location AS Location_4 ON Location_3.sys_whr_id = Location_4.sys_parent_id LEFT OUTER JOIN
Location AS Location_5 ON Location_4.sys_whr_id = Location_5.sys_parent_id LEFT OUTER JOIN
Location AS Location_6 ON Location_5.sys_whr_id = Location_6.sys_parent_id LEFT OUTER JOIN
Location AS Location_7 ON Location_6.sys_whr_id = Location_7.sys_parent_id LEFT OUTER JOIN
Location AS Location_8 ON Location_7.sys_whr_id = Location_8.sys_parent_id LEFT OUTER JOIN
Location AS Location_9 ON Location_8.sys_whr_id = Location_9.sys_parent_id
WHERE (Location.sys_whr_id = 'ONTARIO') // But this would really be a GUID
Which means I have to traverse all the records and fields returned to give me a list of unique ID's and use this as the basis of my next query. Any comments before I put this to bed?
Colin
Bookmarks