在这个例子中,我们有一个SQLite数据库3个相关的表:
CREATE TABLE test1 (
c1 integer,
primary key (c1)
);
CREATE TABLE test2 (
c1 integer,
c2 integer,
primary key (c1, c2)
);
CREATE TABLE test3 (
c2 integer,
c3 integer,
primary key (c2)
);
现在我需要加入所有表:
test1 -> test2 (with c1 column) test2 -> test3 (with c2 column).
我曾尝试这种解决方案,但它不运行:
SELECT
*
FROM test1 a
LEFT OUTER JOIN test2 b
LEFT OUTER JOIN test3 c
ON c.c2 = b.c2
ON b.c1=a.c1
它给我一个错误: near "ON": syntax error.
任何帮助吗?