WHERE NOT some condition
并未从我的查询中排除该条件。
代码:
SELECT
n.timestamp AS tm
FROM
(SELECT timestamp, uid
FROM nodes
UNION ALL
SELECT timestamp, uid FROM ways) n
WHERE
NOT n.uid = '12055' OR NOT n.uid = '2132512';
当前,此查询返回3579897行。
参考:
数据集中的所有时间戳记:
SELECT n.timestamp as tm
FROM (SELECT timestamp FROM nodes UNION ALL SELECT timestamp FROM ways) n;
返回3579897行。
条件的时间戳记:
SELECT n.timestamp as tm
FROM (SELECT timestamp, uid FROM nodes UNION ALL SELECT timestamp, uid FROM ways) n
WHERE n.uid='12055' OR n.uid='2132512'
返回2254097行。
答案 0 :(得分:4)
我想你想要
WHERE NOT n.uid = '12055' AND NOT n.uid = '2132512';
您的版本将返回所有行-一个或其他条件(几乎)始终为真。好的,它将过滤出NULL
的{{1}}个值。
或更雄辩地是:
n.uid
如果WHERE n.uid NOT IN ('12055', '2132512');
是一个数字(我希望如此),则应删除单引号:
uid