I have two PostgreSQL tables containing:
- some objects
- some data about the objects with the type of data
For example:
|---ID---|---NAME---|
| 1 | name1 |
| 2 | name2 |
| 3 | name3 |
|---ID_OBJ---|---TYPE---|---VALUE---|
| 1 | type_1 | val1 |
| 1 | type_2 | val2 |
| 2 | type_1 | val3 |
| 3 | type_2 | val4 |
I want to obtain all the information about each objects on one line. The problem is that I want the values of the nonexistent rows too :
|---NAME---|---TYPE1---|---TYPE2---|
| name1 | val1 | val1 |
| name2 | val3 | NA |
| name3 | NA | val4 |
I don't really understand how to proceed to get this unexistant relationships. Is the EXISTS
keyword a solution?
Edit: I can't activate the tablefunc extension because I don't manage the server myself so the solution explain here can't be easily used.