SQLite User Forum

Unexpected multiple join involving subquery containing cast
Login

Unexpected multiple join involving subquery containing cast

(1) By Zhaokun Xiang (silva9988) on 2025-06-01 12:39:36 [source]

Dear SQLite Developers,

I meet a wrong result. Please see the below cases. I can reproduce it on the version SQLite version SQLite version 3.50.0 and the latest Check-in [b0de22ed0a]. I would like to express my gratitude to your efforts in bug fixing and detained analysis!

CREATE TABLE t0(c0);
CREATE TABLE t1(c0);
CREATE TABLE t2(c0);

INSERT INTO t0 VALUES ('1.0');
INSERT INTO t2(c0) VALUES (9);

SELECT t0.c0,t2.c0 FROM (SELECT CAST(t0.c0 as REAL) AS c0 FROM t0) as subquery NATURAL LEFT JOIN t1  NATURAL JOIN t0  RIGHT JOIN t2 ON 1;
-- Wrong Execution Result: NULL, 9
-- Expected Result: 1.0, 9

(2) By Zhaokun Xiang (silva9988) on 2025-06-03 06:24:55 in reply to 1 [link] [source]

Dear Developers,

I have seen that you have fixed this bug at d6a8b1ea5ca7e0d4. Here I want to express my gratitude to you. Thanks for your fixing!