Check if field exists in json type column PostgreSQL
use ->
:
where (json->'attribute') is not null
While this works. It is better to use special operator ?
:
WHERE your_column_name::jsonb ? 'attribute'
NOTE: Only for jsonb
type.
use ->
:
where (json->'attribute') is not null
While this works. It is better to use special operator ?
:
WHERE your_column_name::jsonb ? 'attribute'
NOTE: Only for jsonb
type.