显示ALL info from T1 and T2 where T1.Catalogue = T2.Catalogue
表格不相等,意味着T2不一定有T1的每一行的信息,但我还是需要显示BOTH TABLES。
我该怎么做?
这不会产生我想要的东西:
select master.*, digital_info.* from master
INNER JOIN digital_info on master.Catalogue = digital_info.Catalogue;
LEFT JOIN也不会产生:
select master.*, digital_info.*
from master
LEFT JOIN digital_info
on master.Catalogue = digital_info.Catalogue;
[[[抱歉也许我的问题相当令人困惑......我已修改过]]]
答案 0 :(得分:2)
SELECT * FROM
T1 LEFT JOIN T2
ON T1.Catalogue = T2.Catalogue
LEFT JOIN:左表中的每个项目都会显示在MySQL结果中,即使它与正在加入的其他表格不匹配。
答案 1 :(得分:2)
SELECT * FROM T1 LEFT JOIN T2 ON T1.Catalogue = T2.Catalogue;
LEFT JOIN关键字返回左表(table_name1)中的所有行,即使右表(table_name2)中没有匹配项也是如此。 (http://www.w3schools.com/sql/sql_join_left.asp)
答案 2 :(得分:2)
这称为左连接。例如:
SELECT *
FROM T1
LEFT JOIN T2 ON T1.Catalogue = T2.Catalogue
答案 3 :(得分:0)
select * from master as m
left outer join digital_info as d on m.Catalogue = d.Catalogue
union
select * from master as m
right outer join digital_info as d on m.Catalogue = d.Catalogue;
这就是你要找的东西吗?