If else with 5 possible cases PostgreSQL
Despite the long comments, it's still not clear if you need one query for each case or a single query that includes all five of them. So, we'll take them separately:


config-&gt;'external_http_port' is null

select * from cameras 
where config-&gt;'external_http_port' is null ;

config-&gt;'external_host' is null
(omitting the select):

where config-&gt;'external_host' is null ;

config-&gt;'snapshots'-&gt;&gt;'jpg' is null

where config-&gt;'snapshots'-&gt;&gt;'jpg' is null ;

all three are null (you got that right!):

where config-&gt;'external_http_port' is null 
  and config-&gt;'external_host' is null 
  and config-&gt;'snapshots'-&gt;&gt;'jpg' is null ;

two out of three are are null (and the third isn't)

where (config-&gt;'external_http_port' is null)::int
      + (config-&gt;'external_host' is null)::int 
      + (config-&gt;'snapshots'-&gt;&gt;'jpg' is null)::int 
      = 2 ;



And if you want all five cases in one query, i.e. any of the five conditions to hold, this can be written (using a complicated condition, similar to the 5th case above):

    where (config-&gt;'external_http_port' is null)::int
          + (config-&gt;'external_host' is null)::int 
          + (config-&gt;'snapshots'-&gt;&gt;'jpg' is null)::int 
          &gt;= 1 ;


or more simply:

    where config-&gt;'external_http_port' is null 
       or config-&gt;'external_host' is null 
       or config-&gt;'snapshots'-&gt;&gt;'jpg' is null ;