1

How can I do a join using table valued function i MSSql 2012 like the query below?

SELECT  m1.id, m1.oid, m1.id2
FROM    dbo.Match(484066) AS m1 INNER JOIN
        dbo.Match(m1.id2) AS m2 ON m1.id2 = m2.id INNER JOIN
        dbo.Match(m2.id2) AS m3 ON m2.id2 = m3.id AND m1.id = m3.id2
infinity1975
  • 403
  • 1
  • 5
  • 10
  • 1
    Or even better, is it possible to rewrite the function using recursive calls on result to get the same result? (lovely would be to have a parameter telling how many times it should do a recursive call, the last call it should always check id2 with 484066(m1.id)) – infinity1975 Aug 30 '15 at 20:26

1 Answers1

3
SELECT  m1.id, m1.oid, m1.id2
FROM    dbo.Match(484066) AS m1 CROSS APPLY
        dbo.Match(m1.id2) AS m2 CROSS APPLY
        dbo.Match(m2.id2) AS m3 

Is this all you wanted?

uh_big_mike_boi
  • 3,350
  • 4
  • 33
  • 64