Question: I have been trying to figure out how to select data related to one id between to tables without limit it to the joined table. I tried using UNION, Inner join, JOIN, but it limit me to show records that are only in both tables. By example: 

```
Table 1 (users)

id | name | register

1  | John | 2014-03-01

2  | Kate | 2014-03-02

```

etc..

```
Table 2 (birthdays by example)

id | user | birthday

1  |  1   | 1989-09-09

```

Note that kate dont have a record on the birthdays table, if i do:

```
SELECT U.id, name, register, B.birthday FROM users as U INNER JOIN birthday as B ON B.user = U.id

```

it will only shows JOHN data, i would like to select all my users and if the record do not exist on the joined table, still be able to select all my users, sort of:

```
id | name | register   | birthday 

1  | John | 2014-03-01 | 1989-09-09

2  | kate | 2014-03-02 | null or ''

3

4

```

etc.

Sorry if its a stupid question but i dont find the light on this one. I would appreciate the help. 

Regards

Answer: 
You need a `LEFT OUTER JOIN` instead of the plain `JOIN` (also known as `INNER JOIN`), like this:

```
SELECT U.id, name, register, B.birthday 
FROM users as U 
LEFT JOIN birthday as B 
ON B.user = U.id

```

A LEFT JOIN between `users` and `birthday` tables will contain all records of the "left" table (users), even if the join-condition does not find any matching record in the "right" table (birthday).

This excellent article on The Code Project will help you a lot: [Visual Representation of SQL Joins](http://www.codeproject.com/KB/database/Visual_SQL_Joins.aspx).

**Summary of all JOIN types**:

![enter image description here](https://i.stack.imgur.com/0Tvgb.png)

Note: Mysql does not support FULL OUTER JOIN but it can be emulated. Useful articles: 

* <https://stackoverflow.com/a/4796911>
* <http://www.sql-tutorial.ru/en/book_full_join_and_mysql.html>
* <http://www.xaprb.com/blog/2006/05/26/how-to-write-full-outer-join-in-mysql/>
Use [left outer join](http://docs.oracle.com/javadb/10.8.1.2/ref/rrefsqlj18922.html) instead of [inner join](http://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqlj35034.html)..

```
SELECT U.id, name, register, B.birthday 
FROM users as U left join birthday as B ON B.user = U.id

```