I have two tables:
formulario_campo ( cod_campo, descricao, cod_formulario )
Filled with the following values
- input_nome, Nome, 1
- input_sexo, Sexo, 1
The second table:
— formulario_valor(cod_campo,valor,cd_oportunidade)
In this table the linked records of the fields and their values are as follows:
- input_name, Fagner, 2
- input_sexo, M, 2
To get the filled values from the formulário_valor
table I make a main select on the formulario_campo
table and then make a left outer join
on the formulario_valor
table to bring the value:
SELECT a.'cod_campo', a.'descricao', b.valor, b.'cod_formulario', b.'cod_oportunidade' FROM formulario_campo a LEFT OUTER JOIN formulario_valor b ON ( a.'cod_campo' = b.'cod_campo' AND a.'cod_formulario' = b.'cod_formulario' ) WHERE b.cod_oportunidade = 145 ORDER BY a.'ordem'
This select returns me the following:
Doubt:addingnewfieldstotheform_fieldtable,forexampleIhavenowaddedanewfieldcalled:input_data_birth,logicallythisfieldhasnovaluesregisteredintheformulario_valor
table,theselectthatI'mdoingaboveshouldnotreturnmeallfieldvaluesthatIhaveregisteredinthe"field_format" table and the input_data_name record came with the value of NULL ?
Attempts I made:
- FULL OUTER JOIN
- LEFT OUTER JOIN
- RIGHT OUTER JOIN
- UNION
But all this I could not bring the new fields that I add with null value ...