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