I have two tables of peoples names and properties. Some have no entries yet and I would like to create a full list of all people and their properties (if available) else have them listed with property "NULL". That's my simplicified example:
names
id     name
-------------
1      Jon
2      Peter
3      Sam
4      Bruce
...
properties
names_id    property
--------------------
1           foo
3           bar
...
desired result:
id     name     property
------------------------
1      Jon      foo
2      Peter    NULL
3      Sam      bar
4      Bruce    NULL
...
Thank you!
Here, using join:
  select A.id, A.name, B.property
    from table1 A
    left outer join table2  B on A.id=B.names_id    
                        You can use left join in this case
select A.id,A.name,B.property
from names A
left join properties B
on A.id=B.names_id ;
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With