使用表值函数加入

时间:2015-08-30 20:24:16

标签: sql-server user-defined-functions

如何使用表值函数i MSSql 2012进行连接,如下面的查询?

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

1 个答案:

答案 0 :(得分: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 

这就是你想要的吗?