sql join two table sql join two table mysql mysql

sql join two table


You can write left outer join between this two tables Best way to understand is check the below image

Query for your requirement

SELECT A.uid, A.name, B.address FROM A LEFT JOIN B ON A.uid=B.uid 

Reading this original article on The Code Project will help you a lot: Visual Representation of SQL Joins.

alt text

Find original one at: Difference between JOIN and OUTER JOIN in MySQL.


SELECT A.uid, A.name, B.address FROM A LEFT OUTER JOIN B ON A.uid = B.uid


You say you tried a left join but didn't give any attempts --- one of the first logical attempts would have been:

SELECT A.uid, A.name, B.addressFROM ALEFT JOIN B ON A.uid=B.uid

Hey presto! it gives you what you were after.