How select data in postgresql using ' where' array string element from jsonb fields?

enter image description here

i have table like above . i want to select the pengumuman field from table using one of element in array from office field . SELECT pengumuman from pengumuman_table where officee ... and i don't know what the next to get data from array with element BWI . how fix that query ? .thanks for your replay

Upvotes: 0

Views: 493

Answers (1)

GMB
GMB

Reputation: 222432

If you want to search the array for a specific value, use any():

select pengumuman
from pengumuman_table
where $1 = any(office)

$1 is the parameter to the query, a literal string to search for in the text arrays.

Upvotes: 2

Related Questions