INNER JOIN与表值函数不起作用 [英] INNER JOIN with Table-Valued Function not working

查看:141
本文介绍了INNER JOIN与表值函数不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表值函数返回一个表。当我尝试 JOIN 表值函数与另一个表我没有得到任何结果,但是当我将该函数的结果复制到一个实际的表中,并执行相同的连接,然后我得到预期的结果。

I have a table valued function that returns a table. When I try to JOIN the table-valued function with another table I don't get any results, but when I copy the result of the function into an actual table and do the same join, then I get expected results.

查询看起来像这样:

The query looks something like this:

Select *
From myTable
INNER JOIN fn_function(@parm1, @param2)
ON ....

我总共有4个这样的查询,每个函数都有不同的功能,但是所有的函数都会产生相同的表格,但是会产生不同的数据。对于其中的一些查询, INNER JOIN 可以工作,但是对于其他查询则不能。

All up I have about 4 such queries and each one has slighly different function, but all the functions produce the same table but different data. For some of these queries the INNER JOIN works, but for others it does not.


推荐答案

使用表值函数,您通常使用交叉应用

With the table valued function you generally use Cross Apply.

Select *
From myTable m
CROSS APPLY fn_function(m.field1, m.field2)

这篇关于INNER JOIN与表值函数不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆