In case it helps...

This problem can be distilled to simply:

CREATE TABLE x(a, b, c);
CREATE TABLE y(a, b);
INSERT INTO x VALUES (1, 0, 1);
INSERT INTO y VALUES (1, 2);

SELECT x.a FROM x JOIN y ON x.c = y.a WHERE x.b = 1 AND x.b = 1;
  --       a
  -- ------------
  --       1 (Not excpected)



-- It seems to have to do with the JOIN condition. Any change in it fixes things:

SELECT x.a FROM x JOIN y ON x.c = 1 WHERE x.b = 1 AND x.b = 1;
  -- No results  (Expected)



-- When I tried re-making it using CTE's, the CTE version worked just fine:

WITH x(a,b,c) AS (
    VALUES (1,0,1)
), y(a,b) AS (
    VALUES (1,2)
)
SELECT x.a FROM x JOIN y ON x.c = y.a WHERE x.b = 1 AND x.b = 1;
  -- No results  (Expected)


HTH,
Ryan



_______________________________________________
sqlite-users mailing list
[email protected]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to