在MS访问查询设计中的此查询中获取缺少运算符错误

时间:2016-06-30 10:28:51

标签: mysql sql access

UPDATE Temp1 a 
  SET TimeStamp1 = CASE(
                     WHEN (a.TimeStamp1 IN
                       (SELECT TimeStamp1 
                          FROM a 
                          WHERE a.DealName = 'Disha Rufous' 
                          AND a.DealStep = 'Sent for Risk feedback')
                       - a.TimeStamp1 IN
                       (SELECT TimeStamp1 
                          FROM a 
                          WHERE a.DealName = 'Disha Rufous' 
                          AND a.DealStep = 'De-dupe confirmation received')
                       IS NOT NULL THEN '0' ELSE TimeStamp1 END) 
  WHERE Temp1.DealName = 'dede' 
  AND Temp1.StepName = 'Risk feedback addressed'

错误表示THEN函数中的CASE

1 个答案:

答案 0 :(得分:0)

您的CASE是:

CASE
    WHEN a IN (X) - a IN (Y) IS NOT NULL
        THEN...
    ELSE ...
END

我想您现在可以看到为什么它不会工作,您的WHEN条款无效。 a IN (X)返回truefalse,从中减去另一个true/false值然后查看它是否为空是没有意义的。

我猜你想要:

UPDATE Temp1 a SET TimeStamp1 = CASE 
                                        WHEN a.TimeStamp1 IN(SELECT TimeStamp1 FROM Temp1 WHERE DealName = 'Disha Rufous' AND DealStep = 'Sent for Risk feedback') 
                                            AND a.TimeStamp1 IN(SELECT TimeStamp1 FROM Temp1 WHERE DealName = 'Disha Rufous' AND DealStep = 'De-dupe confirmation received') 
                                            THEN '0'  
                                        ELSE TimeStamp1 
                                END 
WHERE DealName = 'dede' AND StepName = 'Risk feedback addressed'

根据您的要求,您可能需要在AND子句中将OR更改为WHEN