Oklick
Oklick

Reputation: 41

Why is this code giving me error (postgresql JSONB )?

SELECT  * 
FROM    goods 
WHERE   jsonb_exists_any(params->'sex', array[1, 2, 3, 4, 5])

ERROR: function jsonb_exists_any(jsonb, integer[]) does not exist LINE 1: SELECT * FROM goods WHERE jsonb_exists_any(params->'sex', ar...

Upvotes: 1

Views: 8780

Answers (1)

Evan Carroll
Evan Carroll

Reputation: 1

Call functions that exist, jsonb_exists_any does not exist. Why did you think jsonb_exists_any existed? Was it just a typo?

SELECT  * 
FROM    goods 
WHERE   jsonb_exists_any(params->'sex', array[1, 2, 3, 4, 5])

Find the functions that exist in the latest version here

I'm guessing you want this..

SELECT  * 
FROM    goods 
WHERE   params->'sex' = ANY(ARRAY[1, 2, 3, 4, 5]);

Upvotes: 1

Related Questions