Postgresql: How to select records by column and jsonb array column
You can use the @&gt; operator to check if the array contains a specific element. There is no need to use jsonb_array_elements
SELECT dv.id, dv.device_name, dv.device_subname
FROM devices AS dv
WHERE dv.user_id = 1235
  and (dv.device_name = 'rear light'
       or dv.device_subname @&gt; '[{&quot;name&quot;: &quot;rear light&quot;}]')


Your cross join is essentially an &quot;inner join&quot; so for rows that have no array elements, the row from the base table is not included.
You would have to use an outer join against the array elements if you really wanted to filter in the WHERE clause
SELECT dv.id, dv.device_name, dv.device_subname
FROM devices AS dv
  LEFT JOIN jsonb_array_elements(dv.device_subname) as sub(item) on true
WHERE dv.user_id = 1235
  and (dv.device_name = 'rear light' or sub.item -&gt;&gt; 'name' = 'rear light')

The @&gt; is more efficient though.