使用 Table 值函数加入
Join using Table valued function
如何在 MSSql 2012 中使用 table 值函数进行连接,如下面的查询?
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
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
这就是你想要的吗?
如何在 MSSql 2012 中使用 table 值函数进行连接,如下面的查询?
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
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
这就是你想要的吗?