Unusual two tables join

I have table Persons:

----------------------------------------
id     | name    | phone    | house_id |
----------------------------------------
1      | Sarah   | 1234567  | 101      |
2      | Joseph  | 7654321  | 102      |
3      | David   | 1231231  | null     |

Ans second table Houses:

----------------------------------------
id     | street             | number   |
----------------------------------------
101    | Evergreen Terrace  | 742      |
102    | Baker Street       | 223B     |
103    | Oxford Street      | 23A      |

I need such output table as following:

--------------------------------------------------------------------------------
id(person)| name    | phone    | house_id | id(house) | street        | number |
--------------------------------------------------------------------------------
1         | Sarah   | 1234567  | 101      | 101       | Evergreen T...| 742    |
2         | Joseph  | 7654321  | 102      | 102       | Baker Street  | 223B   |
3         | David   | 1231231  | null     | null      | null          | null   |
4         | null    | null     | null     | 103       | Oxford Street | 23A    |

What kind of join do I need to use to achieve such result?

Answers


SELECT
    A.id AS 'Person',
    A.name,
    A.phone,
    A.house_id,
    B.id AS 'House',
    B.street,
    B.number
FROM
    Persons AS A
    FULL OUTER JOIN Houses AS B
        ON A.house_id = B.id

Need Your Help

perl compare all combinations in hash

perl hash combinations

I need to compare hash elements and pick out all different pairs.

python3 interpreter for emacs instead of 2.7

emacs python-3.x python-2.7 fedora

I'm new to Fedora 17 and Emacs, can't figure out how to tell my emacs to use the newest version of python.