how do I perform a case-insensitive search in a Po

2020-06-23 01:22发布

问题:

i'm using this query to look for data in a table where profile is a JSONB column and it works but only if the name is exactly that

SELECT * FROM "users" WHERE "profile" @> '{"name":"Super User"}'

is it possible to have more flexibility like case insensitivity, wildcards and so on ?

Something like "Super%" or "super user"

回答1:

I found the solution to my problem:

SELECT * FROM "users" WHERE (profile #>> '{name}') ILIKE 'super %'

I don't know if this is performing well enough but it works.
Probably it's wise to add an index to it.