开发者

Better way of writing this SQL WHERE Clause

I have something si开发者_StackOverflow中文版milar 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.


Try:

 AND ipdp.UserID != ISNULL(dbo.fn_userid(ipdp.ItemID), -1)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜