programing

json type 열에 필드가 있는지 확인합니다.SQL

mbctv 2023. 4. 1. 09:52
반응형

json type 열에 필드가 있는지 확인합니다.SQL

어떻게 체크합니까?jsonPostgres의 필드에는 특정 요소가 있습니까?

와 함께 시도했습니다.json->>'attribute' is not null효과가 없습니다.

사용하다->:

where (json->'attribute') is not null

이게 효과가 있을 때.특수 연산자를 사용하는 것이 좋습니다.

WHERE your_column_name::jsonb ? 'attribute'

주의: 대상만jsonb유형.

이는 your_column_name이 json 유형인 경우에도 작동합니다.

SELECT * FROM table_name WHERE your_column_name->>'attribute' is not NULL;

언급URL : https://stackoverflow.com/questions/19422233/check-if-field-exists-in-json-type-column-postgresql

반응형