3
I have these three tables;
table_1 |---------------------| | ID1 | name | |---------------------| | 1 | 'xxxxx' | | 2 | 'xxxxxx' | | 3 | 'xxxxxxxx' | | 4 | 'xxxxxx' | | 5 | 'xxxxxx' | |---------------------| table_2 |---------------------| | ID2 | date | |---------------------| | 1 | '1a' | | 2 | '2b' | | 3 | '3c' | |---------------------| table_3 |--------------------------------------| | ID2_fk | valu | ID1_fk | |--------------------------------------| | 1a | 'value1' | 1 | | 2b | 'value2' | 1 | | 3c | 'value3' | 3 | |--------------------------------------|
and I need to show something similar to this:
Eu preciso de um select que mostra isso
|------------------------------------------------------|
| ID1 | name | 1a | 2b | 3c |
|------------------------------------------------------|
| 1 | 'xxxxx' | 'value1' | 'value2' | |
| 2 | 'xxxxxx' | | | |
| 3 | 'xxxxxxxx' | | | 'value3' |
| 4 | 'xxxxxx' | | | |
| 5 | 'xxxxxx' | | | |
|------------------------------------------------------|
How do I do it? Remember that table_2 varies.
What is the relationship between tables? There are foreign keys between them?
– user28595
The _fk suffix in the column name on table_3 indicates your foreign keys...
– Luiz Carlos Coelho
User an Inner Join only between table 1 and 3
– Fernando Valler
The problem is that I want a select that shows the number of columns according to the amount of values in table 2... can not do this with the Inner...
– Luiz Carlos Coelho