why does filter for NULL
in subqueries does not work?
I hoped to get the correct result by add NULL
to the list of allowed values, for example:
SELECT ERP_ServiceProcess.fiStatusNew, RMA.IdRMA
FROM ERP_ServiceProcess RIGHT OUTER JOIN
RMA ON ERP_ServiceProcess.fiRMA = RMA.IdRMA
WHERE (ERP_ServiceProcess.fiStatusNew IN (NULL, 1, 7, 8))
order by ERP_ServiceProcess.fiStatusNew
这给出了不正确的结果,因为删除了RMA中所有在子表ERP_ServiceProcess(其中ERP_ServiceProcess.fiStatusNew ISNULL
)中没有记录的记录。
我必须使用此(慢速)查询才能获得正确的结果:
SELECT ERP_ServiceProcess.fiStatusNew, RMA.IdRMA
FROM ERP_ServiceProcess RIGHT OUTER JOIN
RMA ON ERP_ServiceProcess.fiRMA = RMA.IdRMA
WHERE (ERP_ServiceProcess.fiStatusNew IS NULL)
OR (ERP_ServiceProcess.fiStatusNew IN (1, 7, 8))
order by ERP_ServiceProcess.fiStatusNew
尽管我使用了<code>RIGHT OUTER JOIN</code>并将<code>NULL</code〕添加到子查询中,但为什么我必须使用第二个较慢的查询?
提前谢谢。