编写此 SQL WHERE 子句的更好方法
我的 SQL 语句中有类似于以下 WHERE
子句的内容:
AND (ipdp.UserID!=dbo.fn_userid(ipdp.ItemID) OR dbo.fn_userid(ipdp.ItemID) IS NULL)
但是,我不喜欢 dbo.fn_userid
函数运行两次。如何改进这行代码,使其只需运行一次?
ipdp.UserID
始终是一个非 NULL 整数值
dbo.fn_userid
可以返回 NULL 或整数值
Cheers。
I have something similar to the following WHERE
clause in my SQL statement:
AND (ipdp.UserID!=dbo.fn_userid(ipdp.ItemID) OR dbo.fn_userid(ipdp.ItemID) IS NULL)
However, I don't like how dbo.fn_userid
function is being ran twice. How can I improve this line of code so that it only has to be ran once?
ipdp.UserID
is always a Non-NULL Integer value
dbo.fn_userid
can return a NULL or an Integer value
Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
Try: