本文介绍了SQL内部联接的空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个加入
SELECT * FROM Y
INNER JOIN X ON ISNULL(X.QID, 0) = ISNULL(y.QID, 0)
这样的Join中的
Isnull
会使它变慢.就像有条件加入.是否有类似的解决方法?我有很多记录,其中QID
为Null
Isnull
in a Join like this makes it slow. It's like having a conditional Join.Is there any work around to something like this?I have a lot of records where QID
is Null
任何人都可以解决,无需修改数据
Anyone have a work around that doesn't entail modifying the data
推荐答案
您有两个选择
INNER JOIN x
ON x.qid = y.qid OR (x.qid IS NULL AND y.qid IS NULL)
或更简单
INNER JOIN x
ON x.qid IS NOT DISTINCT FROM y.qid
这篇关于SQL内部联接的空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!