1
I’m doing an SQL query, in Oracle database, but one of the fields returns the empty value, different from the table in the database.
I have tried to create, and rebuild the indexes, but the problem persists.
The field itself refers to a left join
that I do on the chart.
When I just put the field in select
, value returns, but I need more fields in select
.
Example:
SELECT
A.CAMPO1,
A.CAMPO2,
B.CAMPO3 -- CAMPO RETORNANDO VAZIO
FROM TABELAA A
LEFT JOIN TABELAB B
ON A.CAMPO1 = B.CAMPO.1
Hi, can you drill in better, please? What I got: Table B’s field3 is returning empty when used Left Join. If this is all, field 1 of table A is equal to field 1 of table B?
– Victor Freidinger
Raphael, try to reproduce the same data here on SQL Fiddle, if the problem persists change your question and put the fiddle link.
– Laércio Lopes
You are using LEFT JOIN. This means that if CAMPO1 exists in the TABLE but not in the TABLE then all fields in the TABLE will return NULL. That’s what you expect from LEFT JOIN.
– anonimo
Put the structure of the tables and some data to give to better understand. If it is bringing null value it is because it is null in the table, LEFT JOIN does just that...if you do not want it to bring fields that are not null use INNER JOIN it will bring records that have values in the fields you are selecting in your SELECT
– Rogerio Pavan da Silva