How to return NULL in LEFT JOIN? [closed]

1

I have 2 tables that I need to manipulate:

  • intervencaoprioridade: idintervencaoprioridade, idcelula ...
  • cell: idcelula, name ...

    SELECT ip.idintervencaoprioridade, zc.nome nome_celula 
    FROM intervencaoprioridade ip 
    LEFT JOIN celula zc ON ip.idcelula = zc.idcelula 
    WHERE ip.idintervencaoprioridade = 22
    

The field ip.idcelula can be NULL , but when I do this query it returns the first record of the celula table. I've seen other examples in SO , but I did not see anything that would help me.

    
asked by anonymous 14.10.2015 / 19:07

1 answer

1

This can happen to more users as in my case, I leave my answer and solution if it is useful to others.

When I tested for a id = 22 it did not have the field idcelula to null so it returns another value that by coincidence was the first. Taking the test more carefully I noticed that, and changed the test record to one that had idcelula to null .

    
15.10.2015 / 03:05