本文介绍了如果 join 返回 null,则在默认行上加入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
我正在尝试将 2 个表连接到一行,如果该行为空,则将该行连接到默认行.
I am trying to join 2 tables on a row, and if that row is null, then join that row to the default row.
表 1:事件
表 2:菜单
我的尝试
我得到的输出
在这种情况下,Menus
表的默认行是具有最高 MenuID
和空 EventID
的行.
The default row of the Menus
table in this case is the row with the highest MenuID
and a null EventID
.
我想要的输出
推荐答案
交叉应用
默认行,并在没有行被left join
打开时使用其值.
Cross apply
the default row and use its values when no row is left join
ed on.
按要求返回:
注意:如果您将来使用 DDL/DML 语句提出这样的问题,您会得到更快的答复,因为它使人们不必全部输入.
Note: If you set out your questions like this in future with the DDL/DML statements you'll get a much faster response because it saves people from having to type it all in.
这篇关于如果 join 返回 null,则在默认行上加入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!