Reputation: 2343
Ineed to display ALL info from T1 and T2 where T1.Catalogue = T2.Catalogue
The tables are NOT equal, meaning T2 not necessarily has info for each row of T1, but I need BOTH TABLES to be displayed anyway.
How do I do this please?
This will not produce what I want:
select master.*, digital_info.* from master
INNER JOIN digital_info on master.Catalogue = digital_info.Catalogue;
neither will LEFT JOIN produce:
select master.*, digital_info.*
from master
LEFT JOIN digital_info
on master.Catalogue = digital_info.Catalogue;
[[[ sorry perhaps my question was rather confusing... i've amended it ]]]
Upvotes: 1
Views: 2605
Reputation: 1617
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;
is this what you are looking for?
Upvotes: 0
Reputation: 36999
This is called a left join. Example:
SELECT *
FROM T1
LEFT JOIN T2 ON T1.Catalogue = T2.Catalogue
Upvotes: 2
Reputation: 2879
SELECT * FROM T1 LEFT JOIN T2 ON T1.Catalogue = T2.Catalogue;
The LEFT JOIN keyword returns all rows from the left table (table_name1), even if there are no matches in the right table (table_name2). (http://www.w3schools.com/sql/sql_join_left.asp)
Upvotes: 2
Reputation: 86406
SELECT * FROM
T1 LEFT JOIN T2
ON T1.Catalogue = T2.Catalogue
LEFT JOIN: Each item in the left table will show up in a MySQL result, even if there isn't a match with the other table that it is being joined to.
Upvotes: 2