我有两个表,如下所示 TableA为
col1 col2 col3 col4
1 2 3 4
101 201 301 401
和另一个表tableB
col1 col2 col3 col4
1 2 3 4
结果表C或结果应为
结果
col1 col2 col3 col4 col5 col6 col7 col8
1 2 3 4 1 2 3 4
101 201 301 401 null null null null
基本上希望在可用的地方将公用行保存在表中。 我正在使用MYSQL
答案 0 :(得分:1)
select * from TableA a left join TableB b
on a.col1 = b.col1 and a.col2 = b.col2 and a.col3 = b.col3 and a.col4 = b.col4