I did look at that although I didn't read what each line was for until you pointed it out, so thank you for that as I ended up using a version of the last line in that query.
I ended up using this in my item transformation
<script runat="server">
  protected override void OnInit(EventArgs e)
  {
      base.OnInit(e);
      rptRelated.WhereCondition = "DocumentID in (SELECT DISTINCT DocumentID FROM CMS_DocumentTag WHERE TagID IN (SELECT TagID FROM CMS_DocumentTag WHERE DocumentID = " + ValidationHelper.GetInteger(Eval("DocumentID"), 0).ToString() + ") AND DocumentID <> " + ValidationHelper.GetInteger(Eval("DocumentID"), 0).ToString() + ")";
      rptRelated.ReloadData(true);               
  }
</script>
along with a repeater in my transformation.