我已经运行了这两个看起来像是做同样事情的查询,但给出了不同的结果:
SELECT COUNT(stage1) AS total
FROM progress_status
WHERE stage1 = 3
AND stage2 != 3 AND stage3 !=3 AND stage4 !=3 AND stage5 !=3;
# total = 90
SELECT COUNT(stage1) AS total
FROM progress_status
WHERE stage1 = 3
AND (stage2,stage3,stage4,stage5) != (3,3,3,3)
# total = 314
答案 0 :(得分:5)
第二个是:
AND (stage2 != 3 OR stage3 !=3 OR stage4 !=3 OR stage5 !=3);
答案 1 :(得分:3)
这是正常的:
OR
子句中使用WHERE
一样。答案 2 :(得分:2)
(stage2,stage3,stage4,stage5) != (3,3,3,3)
时, stage2 != 3 OR stage3 !=3 OR stage4 !=3 OR stage5 !=3
为真