IDS 9.40写嵌套子查询的奇怪问题
测试的SQL如下:
SELECT serv_id FROM serv_65 where serv_id = 148951
无数据返回。
SELECT a.acc_nbr, a.serv_id, a.state FROM f_serv a
WHERE a.state in ( 'F0A ', 'F0J ')
AND a.serv_id NOT IN (SELECT serv_id FROM serv_65 where serv_id = 148951)
AND a.completed_date <= '2007-01-31 23:59:59 '
AND a.serv_id = 148951
返回一条数据,其serv_id = 148951。
但把子查询里的条件去掉后:
SELECT a.acc_nbr, a.serv_id, a.state FROM f_serv a
WHERE a.state in ( 'F0A ', 'F0J ')
AND a.serv_id NOT IN (SELECT serv_id FROM serv_65)
AND a.completed_date <= '2007-01-31 23:59:59 '
AND a.serv_id = 148951
却无数据返回。
实在百思不得其解。请各位仁兄解惑。
[解决办法]
也感觉有点奇怪,不过感觉这条语句 AND a.serv_id NOT IN (SELECT serv_id FROM serv_65 where serv_id = 148951) , not in之后的子查询中没有输出结果,不知道会产生什么结果。