为什么此查询的where子句评估为false?

时间:2016-09-12 21:54:12

标签: sql amazon-redshift

我试图理解为什么此Redshift查询的WHERE子句正在评估FALSE而不返回任何结果。

CREATE TEMPORARY TABLE temp AS (SELECT 1 AS id);

问题:此查询不返回任何结果 -

SELECT *
FROM (
  SELECT
    id,
    FALSE as test
  FROM temp)
WHERE test = FALSE;

此查询返回预期的一行 -

SELECT *
FROM (
  SELECT
    id,
    (SELECT FALSE) as test
  FROM temp)
WHERE test = FALSE;

另外,这可以正常工作 -

CREATE TEMPORARY TABLE temp2 AS (SELECT 1 AS id, FALSE AS test);

SELECT *
FROM (
  SELECT
    id,
    test
  FROM temp)
WHERE test = FALSE;

0 个答案:

没有答案