ClickHouse/tests/queries/0_stateless/02372_analyzer_join.reference
2022-10-24 10:22:19 +02:00

741 lines
32 KiB
Plaintext

-- { echoOn }
SELECT 'JOIN INNER';
JOIN INNER
SELECT 'Join without ON conditions';
Join without ON conditions
SELECT test_table_join_1.id, test_table_join_1.value, test_table_join_2.id, test_table_join_2.value
FROM test_table_join_1 INNER JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
SELECT '--';
--
SELECT t1.id, test_table_join_1.id, t1.value, test_table_join_1.value, t2.id, test_table_join_2.id, t2.value, test_table_join_2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
0 0 Join_1_Value_0 Join_1_Value_0 0 0 Join_2_Value_0 Join_2_Value_0
1 1 Join_1_Value_1 Join_1_Value_1 1 1 Join_2_Value_1 Join_2_Value_1
SELECT '--';
--
SELECT test_table_join_1.id, test_table_join_1.value, test_table_join_2.id, test_table_join_2.value, test_table_join_3.id, test_table_join_3.value
FROM test_table_join_1 INNER JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id
INNER JOIN test_table_join_3 ON test_table_join_2.id = test_table_join_3.id;
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 1 Join_2_Value_1 1 Join_3_Value_1
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id
INNER JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 1 Join_2_Value_1 1 Join_3_Value_1
SELECT '--';
--
SELECT t1.id, test_table_join_1.id, t1.value, test_table_join_1.value, t2.id, test_table_join_2.id, t2.value, test_table_join_2.value,
t3.id, test_table_join_3.id, t3.value, test_table_join_3.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id
INNER JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
0 0 Join_1_Value_0 Join_1_Value_0 0 0 Join_2_Value_0 Join_2_Value_0 0 0 Join_3_Value_0 Join_3_Value_0
1 1 Join_1_Value_1 Join_1_Value_1 1 1 Join_2_Value_1 Join_2_Value_1 1 1 Join_3_Value_1 Join_3_Value_1
SELECT id FROM test_table_join_1 INNER JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id; -- { serverError 36 }
SELECT value FROM test_table_join_1 INNER JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id; -- { serverError 36 }
SELECT 'Join with ON conditions';
Join with ON conditions
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value = 'Join_1_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value = 'Join_1_Value_0' AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON toString(t1.id) = toString(t2.id) AND t1.value = 'Join_1_Value_0' AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value == 'Join_2_Value_0'
INNER JOIN test_table_join_3 AS t3 ON t2.id = t3.id AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value == 'Join_1_Value_0' AND t2.value == 'Join_2_Value_0'
INNER JOIN test_table_join_3 AS t3 ON t2.id = t3.id AND t2.value == 'Join_2_Value_0' AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value == 'Join_2_Value_0'
INNER JOIN test_table_join_3 AS t3 ON t1.id = t3.id AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value == 'Join_1_Value_0' AND t2.value == 'Join_2_Value_0'
INNER JOIN test_table_join_3 AS t3 ON t1.id = t3.id AND t2.value == 'Join_2_Value_0' AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON toString(t1.id) = toString(t2.id) AND t2.value == 'Join_2_Value_0'
INNER JOIN test_table_join_3 AS t3 ON toString(t2.id) = toString(t3.id) AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
SELECT 'Join only join expression use keys';
Join only join expression use keys
SELECT t1.value, t2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0
Join_1_Value_1 Join_2_Value_1
SELECT '--';
--
SELECT t1.value, t2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0
Join_1_Value_1 Join_2_Value_1
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id
INNER JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id
INNER JOIN test_table_join_3 AS t3 ON t1.id = t3.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
SELECT 'Join multiple clauses';
Join multiple clauses
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id OR t1.id = t2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id OR t1.id = t2.id
INNER JOIN test_table_join_3 AS t3 ON t1.id = t3.id OR t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_0 Join_2_Value_0 Join_3_Value_1
Join_1_Value_0 Join_2_Value_0 Join_3_Value_2
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
Join_1_Value_1 Join_2_Value_1 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_2
SELECT 'Join expression aliases';
Join expression aliases
SELECT t1_id, t1.value, t2_id, t2.value FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON (t1.id AS t1_id) = (t2.id AS t2_id);
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
SELECT '--';
--
SELECT t1.id AS t1_id, t1.value, t2.id AS t2_id, t2.value FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1_id = t2_id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
SELECT 'JOIN LEFT';
JOIN LEFT
SELECT 'Join without ON conditions';
Join without ON conditions
SELECT test_table_join_1.id, test_table_join_1.value, test_table_join_2.id, test_table_join_2.value
FROM test_table_join_1 LEFT JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
2 Join_1_Value_3 0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
2 Join_1_Value_3 0
SELECT '--';
--
SELECT t1.id, test_table_join_1.id, t1.value, test_table_join_1.value, t2.id, test_table_join_2.id, t2.value, test_table_join_2.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
0 0 Join_1_Value_0 Join_1_Value_0 0 0 Join_2_Value_0 Join_2_Value_0
1 1 Join_1_Value_1 Join_1_Value_1 1 1 Join_2_Value_1 Join_2_Value_1
2 2 Join_1_Value_3 Join_1_Value_3 0 0
SELECT '--';
--
SELECT test_table_join_1.id, test_table_join_1.value, test_table_join_2.id, test_table_join_2.value, test_table_join_3.id, test_table_join_3.value
FROM test_table_join_1 LEFT JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id
LEFT JOIN test_table_join_3 ON test_table_join_2.id = test_table_join_3.id;
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 1 Join_2_Value_1 1 Join_3_Value_1
2 Join_1_Value_3 0 0 Join_3_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id
LEFT JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 1 Join_2_Value_1 1 Join_3_Value_1
2 Join_1_Value_3 0 0 Join_3_Value_0
SELECT '--';
--
SELECT t1.id, test_table_join_1.id, t1.value, test_table_join_1.value, t2.id, test_table_join_2.id, t2.value, test_table_join_2.value,
t3.id, test_table_join_3.id, t3.value, test_table_join_3.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id
LEFT JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
0 0 Join_1_Value_0 Join_1_Value_0 0 0 Join_2_Value_0 Join_2_Value_0 0 0 Join_3_Value_0 Join_3_Value_0
1 1 Join_1_Value_1 Join_1_Value_1 1 1 Join_2_Value_1 Join_2_Value_1 1 1 Join_3_Value_1 Join_3_Value_1
2 2 Join_1_Value_3 Join_1_Value_3 0 0 0 0 Join_3_Value_0 Join_3_Value_0
SELECT id FROM test_table_join_1 LEFT JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id; -- { serverError 36 }
SELECT value FROM test_table_join_1 LEFT JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id; -- { serverError 36 }
SELECT 'Join with ON conditions';
Join with ON conditions
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value = 'Join_1_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 0
2 Join_1_Value_3 0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value = 'Join_1_Value_0' AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 0
2 Join_1_Value_3 0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON toString(t1.id) = toString(t2.id) AND t1.value = 'Join_1_Value_0' AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 0
2 Join_1_Value_3 0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value == 'Join_2_Value_0'
LEFT JOIN test_table_join_3 AS t3 ON t2.id = t3.id AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 0 0 Join_3_Value_0
2 Join_1_Value_3 0 0 Join_3_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value == 'Join_1_Value_0' AND t2.value == 'Join_2_Value_0'
LEFT JOIN test_table_join_3 AS t3 ON t2.id = t3.id AND t2.value == 'Join_2_Value_0' AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 0 0
2 Join_1_Value_3 0 0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value == 'Join_2_Value_0'
LEFT JOIN test_table_join_3 AS t3 ON t1.id = t3.id AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 0 0
2 Join_1_Value_3 0 0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value == 'Join_1_Value_0' AND t2.value == 'Join_2_Value_0'
LEFT JOIN test_table_join_3 AS t3 ON t1.id = t3.id AND t2.value == 'Join_2_Value_0' AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 0 0
2 Join_1_Value_3 0 0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON toString(t1.id) = toString(t2.id) AND t2.value == 'Join_2_Value_0'
LEFT JOIN test_table_join_3 AS t3 ON toString(t2.id) = toString(t3.id) AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 0 0 Join_3_Value_0
2 Join_1_Value_3 0 0 Join_3_Value_0
SELECT 'Join only join expression use keys';
Join only join expression use keys
SELECT t1.value, t2.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0
Join_1_Value_1 Join_2_Value_1
Join_1_Value_3
SELECT '--';
--
SELECT t1.value, t2.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0
Join_1_Value_1 Join_2_Value_1
Join_1_Value_3
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id
LEFT JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
Join_1_Value_3 Join_3_Value_0
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id
LEFT JOIN test_table_join_3 AS t3 ON t1.id = t3.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
Join_1_Value_3
SELECT 'Join multiple clauses';
Join multiple clauses
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id OR t1.id = t2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
2 Join_1_Value_3 0
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
LEFT JOIN test_table_join_2 AS t2 ON t1.id = t2.id OR t1.id = t2.id
LEFT JOIN test_table_join_3 AS t3 ON t1.id = t3.id OR t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_0 Join_2_Value_0 Join_3_Value_1
Join_1_Value_0 Join_2_Value_0 Join_3_Value_2
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
Join_1_Value_1 Join_2_Value_1 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_2
Join_1_Value_3
SELECT 'Join expression aliases';
Join expression aliases
SELECT t1_id, t1.value, t2_id, t2.value FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON (t1.id AS t1_id) = (t2.id AS t2_id);
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
2 Join_1_Value_3 0
SELECT '--';
--
SELECT t1.id AS t1_id, t1.value, t2.id AS t2_id, t2.value FROM test_table_join_1 AS t1 LEFT JOIN test_table_join_2 AS t2 ON t1_id = t2_id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
2 Join_1_Value_3 0
SELECT 'JOIN RIGHT';
JOIN RIGHT
SELECT 'Join without ON conditions';
Join without ON conditions
SELECT test_table_join_1.id, test_table_join_1.value, test_table_join_2.id, test_table_join_2.value
FROM test_table_join_1 RIGHT JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id, test_table_join_1.id, t1.value, test_table_join_1.value, t2.id, test_table_join_2.id, t2.value, test_table_join_2.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
0 0 Join_1_Value_0 Join_1_Value_0 0 0 Join_2_Value_0 Join_2_Value_0
1 1 Join_1_Value_1 Join_1_Value_1 1 1 Join_2_Value_1 Join_2_Value_1
0 0 3 3 Join_2_Value_2 Join_2_Value_2
SELECT '--';
--
SELECT test_table_join_1.id, test_table_join_1.value, test_table_join_2.id, test_table_join_2.value, test_table_join_3.id, test_table_join_3.value
FROM test_table_join_1 RIGHT JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id
RIGHT JOIN test_table_join_3 ON test_table_join_2.id = test_table_join_3.id;
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 1 Join_2_Value_1 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id
RIGHT JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 1 Join_2_Value_1 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, test_table_join_1.id, t1.value, test_table_join_1.value, t2.id, test_table_join_2.id, t2.value, test_table_join_2.value,
t3.id, test_table_join_3.id, t3.value, test_table_join_3.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id
RIGHT JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
0 0 Join_1_Value_0 Join_1_Value_0 0 0 Join_2_Value_0 Join_2_Value_0 0 0 Join_3_Value_0 Join_3_Value_0
1 1 Join_1_Value_1 Join_1_Value_1 1 1 Join_2_Value_1 Join_2_Value_1 1 1 Join_3_Value_1 Join_3_Value_1
0 0 0 0 4 4 Join_3_Value_2 Join_3_Value_2
SELECT id FROM test_table_join_1 RIGHT JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id; -- { serverError 36 }
SELECT value FROM test_table_join_1 RIGHT JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id; -- { serverError 36 }
SELECT 'Join with ON conditions';
Join with ON conditions
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value = 'Join_1_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
0 1 Join_2_Value_1
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value = 'Join_1_Value_0' AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
0 1 Join_2_Value_1
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON toString(t1.id) = toString(t2.id) AND t1.value = 'Join_1_Value_0' AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
0 1 Join_2_Value_1
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value == 'Join_2_Value_0'
RIGHT JOIN test_table_join_3 AS t3 ON t2.id = t3.id AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
0 0 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value == 'Join_1_Value_0' AND t2.value == 'Join_2_Value_0'
RIGHT JOIN test_table_join_3 AS t3 ON t2.id = t3.id AND t2.value == 'Join_2_Value_0' AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
0 0 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value == 'Join_2_Value_0'
RIGHT JOIN test_table_join_3 AS t3 ON t1.id = t3.id AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
0 1 Join_2_Value_1 0 Join_3_Value_0
0 3 Join_2_Value_2 0 Join_3_Value_0
0 0 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value == 'Join_1_Value_0' AND t2.value == 'Join_2_Value_0'
RIGHT JOIN test_table_join_3 AS t3 ON t1.id = t3.id AND t2.value == 'Join_2_Value_0' AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
0 0 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON toString(t1.id) = toString(t2.id) AND t2.value == 'Join_2_Value_0'
RIGHT JOIN test_table_join_3 AS t3 ON toString(t2.id) = toString(t3.id) AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
0 0 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT 'Join only join expression use keys';
Join only join expression use keys
SELECT t1.value, t2.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0
Join_1_Value_1 Join_2_Value_1
Join_2_Value_2
SELECT '--';
--
SELECT t1.value, t2.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0
Join_1_Value_1 Join_2_Value_1
Join_2_Value_2
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id
RIGHT JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
Join_3_Value_2
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id
RIGHT JOIN test_table_join_3 AS t3 ON t1.id = t3.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
Join_2_Value_2 Join_3_Value_0
Join_3_Value_2
SELECT 'Join multiple clauses';
Join multiple clauses
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id OR t1.id = t2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
RIGHT JOIN test_table_join_2 AS t2 ON t1.id = t2.id OR t1.id = t2.id
RIGHT JOIN test_table_join_3 AS t3 ON t1.id = t3.id OR t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_0 Join_2_Value_0 Join_3_Value_1
Join_1_Value_0 Join_2_Value_0 Join_3_Value_2
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
Join_1_Value_1 Join_2_Value_1 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_2
Join_2_Value_2 Join_3_Value_0
SELECT 'Join expression aliases';
Join expression aliases
SELECT t1_id, t1.value, t2_id, t2.value FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON (t1.id AS t1_id) = (t2.id AS t2_id);
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id AS t1_id, t1.value, t2.id AS t2_id, t2.value FROM test_table_join_1 AS t1 RIGHT JOIN test_table_join_2 AS t2 ON t1_id = t2_id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
0 3 Join_2_Value_2
SELECT 'JOIN FULL';
JOIN FULL
SELECT 'Join without ON conditions';
Join without ON conditions
SELECT test_table_join_1.id, test_table_join_1.value, test_table_join_2.id, test_table_join_2.value
FROM test_table_join_1 FULL JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
2 Join_1_Value_3 0
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
2 Join_1_Value_3 0
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id, test_table_join_1.id, t1.value, test_table_join_1.value, t2.id, test_table_join_2.id, t2.value, test_table_join_2.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
0 0 Join_1_Value_0 Join_1_Value_0 0 0 Join_2_Value_0 Join_2_Value_0
1 1 Join_1_Value_1 Join_1_Value_1 1 1 Join_2_Value_1 Join_2_Value_1
2 2 Join_1_Value_3 Join_1_Value_3 0 0
0 0 3 3 Join_2_Value_2 Join_2_Value_2
SELECT '--';
--
SELECT test_table_join_1.id, test_table_join_1.value, test_table_join_2.id, test_table_join_2.value, test_table_join_3.id, test_table_join_3.value
FROM test_table_join_1 FULL JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id
FULL JOIN test_table_join_3 ON test_table_join_2.id = test_table_join_3.id;
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 1 Join_2_Value_1 1 Join_3_Value_1
2 Join_1_Value_3 0 0 Join_3_Value_0
0 3 Join_2_Value_2 0
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id
FULL JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 1 Join_2_Value_1 1 Join_3_Value_1
2 Join_1_Value_3 0 0 Join_3_Value_0
0 3 Join_2_Value_2 0
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, test_table_join_1.id, t1.value, test_table_join_1.value, t2.id, test_table_join_2.id, t2.value, test_table_join_2.value,
t3.id, test_table_join_3.id, t3.value, test_table_join_3.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id
FULL JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
0 0 Join_1_Value_0 Join_1_Value_0 0 0 Join_2_Value_0 Join_2_Value_0 0 0 Join_3_Value_0 Join_3_Value_0
1 1 Join_1_Value_1 Join_1_Value_1 1 1 Join_2_Value_1 Join_2_Value_1 1 1 Join_3_Value_1 Join_3_Value_1
2 2 Join_1_Value_3 Join_1_Value_3 0 0 0 0 Join_3_Value_0 Join_3_Value_0
0 0 3 3 Join_2_Value_2 Join_2_Value_2 0 0
0 0 0 0 4 4 Join_3_Value_2 Join_3_Value_2
SELECT id FROM test_table_join_1 FULL JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id; -- { serverError 36 }
SELECT value FROM test_table_join_1 FULL JOIN test_table_join_2 ON test_table_join_1.id = test_table_join_2.id; -- { serverError 36 }
SELECT 'Join with ON conditions';
Join with ON conditions
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 INNER JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value = 'Join_1_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 0
2 Join_1_Value_3 0
0 1 Join_2_Value_1
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value = 'Join_1_Value_0' AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 0
2 Join_1_Value_3 0
0 1 Join_2_Value_1
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON toString(t1.id) = toString(t2.id) AND t1.value = 'Join_1_Value_0' AND t2.value = 'Join_2_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 0
2 Join_1_Value_3 0
0 1 Join_2_Value_1
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value == 'Join_2_Value_0'
FULL JOIN test_table_join_3 AS t3 ON t2.id = t3.id AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 0 0 Join_3_Value_0
2 Join_1_Value_3 0 0 Join_3_Value_0
0 1 Join_2_Value_1 0
0 3 Join_2_Value_2 0
0 0 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value == 'Join_1_Value_0' AND t2.value == 'Join_2_Value_0'
FULL JOIN test_table_join_3 AS t3 ON t2.id = t3.id AND t2.value == 'Join_2_Value_0' AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 0 0
2 Join_1_Value_3 0 0
0 1 Join_2_Value_1 0
0 3 Join_2_Value_2 0
0 0 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t2.value == 'Join_2_Value_0'
FULL JOIN test_table_join_3 AS t3 ON t1.id = t3.id AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 0 0
2 Join_1_Value_3 0 0
0 1 Join_2_Value_1 0 Join_3_Value_0
0 3 Join_2_Value_2 0 Join_3_Value_0
0 0 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id AND t1.value == 'Join_1_Value_0' AND t2.value == 'Join_2_Value_0'
FULL JOIN test_table_join_3 AS t3 ON t1.id = t3.id AND t2.value == 'Join_2_Value_0' AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 0 0
2 Join_1_Value_3 0 0
0 1 Join_2_Value_1 0
0 3 Join_2_Value_2 0
0 0 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT '--';
--
SELECT t1.id, t1.value, t2.id, t2.value, t3.id, t3.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON toString(t1.id) = toString(t2.id) AND t2.value == 'Join_2_Value_0'
FULL JOIN test_table_join_3 AS t3 ON toString(t2.id) = toString(t3.id) AND t3.value == 'Join_3_Value_0';
0 Join_1_Value_0 0 Join_2_Value_0 0 Join_3_Value_0
1 Join_1_Value_1 0 0 Join_3_Value_0
2 Join_1_Value_3 0 0 Join_3_Value_0
0 1 Join_2_Value_1 0
0 3 Join_2_Value_2 0
0 0 1 Join_3_Value_1
0 0 4 Join_3_Value_2
SELECT 'Join only join expression use keys';
Join only join expression use keys
SELECT t1.value, t2.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0
Join_1_Value_1 Join_2_Value_1
Join_1_Value_3
Join_2_Value_2
SELECT '--';
--
SELECT t1.value, t2.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0
Join_1_Value_1 Join_2_Value_1
Join_1_Value_3
Join_2_Value_2
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id
FULL JOIN test_table_join_3 AS t3 ON t2.id = t3.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
Join_1_Value_3 Join_3_Value_0
Join_2_Value_2
Join_3_Value_2
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id
FULL JOIN test_table_join_3 AS t3 ON t1.id = t3.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
Join_1_Value_3
Join_2_Value_2 Join_3_Value_0
Join_3_Value_2
SELECT 'Join multiple clauses';
Join multiple clauses
SELECT t1.id, t1.value, t2.id, t2.value
FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id OR t1.id = t2.id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
2 Join_1_Value_3 0
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.value, t2.value, t3.value
FROM test_table_join_1 AS t1
FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id OR t1.id = t2.id
FULL JOIN test_table_join_3 AS t3 ON t1.id = t3.id OR t1.id = t2.id;
Join_1_Value_0 Join_2_Value_0 Join_3_Value_0
Join_1_Value_0 Join_2_Value_0 Join_3_Value_1
Join_1_Value_0 Join_2_Value_0 Join_3_Value_2
Join_1_Value_1 Join_2_Value_1 Join_3_Value_1
Join_1_Value_1 Join_2_Value_1 Join_3_Value_0
Join_1_Value_1 Join_2_Value_1 Join_3_Value_2
Join_1_Value_3
Join_2_Value_2 Join_3_Value_0
SELECT 'Join expression aliases';
Join expression aliases
SELECT t1_id, t1.value, t2_id, t2.value FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON (t1.id AS t1_id) = (t2.id AS t2_id);
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
2 Join_1_Value_3 0
0 3 Join_2_Value_2
SELECT '--';
--
SELECT t1.id AS t1_id, t1.value, t2.id AS t2_id, t2.value FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1_id = t2_id;
0 Join_1_Value_0 0 Join_2_Value_0
1 Join_1_Value_1 1 Join_2_Value_1
2 Join_1_Value_3 0
0 3 Join_2_Value_2