title: While Loop insteads of many nested selects
body: <p>Trying to do a While Loop instead of many nested selects:</p>
  
  <pre><code>Table A 
  ID  ItemID
  1   12
  2   13
  3   14
  4   15
  5   16
  6   17
  11  19
  
  Table B 
  BID ItemID
  8   10
  7   11
  6   12
  9   13
  10  14
  11  17
  </code></pre>
  
  <p>Joining A.ItemID to B.ItemID to get the BID
  Once I get the BID, I need to join this back to the A.ID to get the relevant A.ItemID to join this back to B.BID to get the next B.ItemID and so on untill the BID is NULL</p>
  
  <p>So for example Table A ID 1 (ItemID 12) will link to B.ItemID 12 to retrieve the BID 6, This will link back to Table A ID 6 to get ItemID 17, this will link to Table B ItemID 17 to get BID 11 to link back to Table A on ID 11 to get ItemID 19 and so on until BID is NULL</p>
  
  <p>This could go 10-15 levels deep, so a nested select is not dynamic enough, so I need to achieve this in a While Loop</p>
  
  <p>Any ideas please??</p>