我想加入以下三个表,我的条件是 t1.eid = 1。加入表后,我想用 0 填充空表单元格。我想先加入 t1 和 t2,其中 t1.eid=1,然后将结果与 t3 连接起来,其中将两个表的结果与 t3 连接起来,其中 t3.vid= 新的 result.vid。
数据样本:
CREATE TABLE t1 (
sid INT,
fid INT,
eid INT,
i INT,
uid INT);
INSERT INTO t1 (sid, fid, i, eid, uid) VALUES (1, 1, 1, 1, 1), (2, 2, 1, 1, 2), (3, 1,
1, 2, 1), (4, 2, 1, 2, 2), (5, 1, 1, 3, 1), (6, 2, 1, 3, 2), (7, 1, 1, 1, 3);
CREATE TABLE t2 (
d INT,
vid INT,
eid INT
);
INSERT INTO t2( d, vid, eid ) VALUES ( 1, 1, 1 ) , ( 1, 2, 1 ) , ( 1, 3, 2 ) , ( 1, 4,
2 ) , ( 1, 5, 3 ) , ( 1, 6, 3 ) ;
CREATE TABLE t3 (
vid INT,
fr INT,
sr INT,
aj INT,
sj INT,
fid INT,
uid INT
);
INSERT INTO t3( vid, fr, sr, aj, sj, fid, uid ) VALUES ( 1, 0, 100, 0.1, 1, 1, 1 ) , (
2, 0, 1000, 1, 1, 2, 2 ) , ( 3, 0, 300, 0.1, 1, 1, 1 ) , ( 4, 0, 200, 1, 1, 2, 2 ) , (
5, 0, 1000, 0.25, 10, 1, 1 ) , ( 6, 0, 200, 1, 1, 2, 2 ) , ( 7, 0, 150, 1, 0.1, 1, 1 )
, ( 8, 0, 350, 1, 0.1, 1, 1 ) , ( 9, 0, 1050, 10, 0.25, 1, 1 ) , ( 10, 0, 1050, 1, 0,
2, 2 ) , ( 11, 0, 250, 1, 0, 2, 2 ) , ( 12, 0, 250, 1, 0, 2, 2 ) ;