© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•3y ago
G O A T

How to Access an array of strings in jsonb format

I am trying to find records where slug (predefined variable) is found in an array in my jsonb players column. The value looks like this:

['John', 'James', 'Joe', 'Jack']

If slug = John then this should return the record.

My below query does not work:

const result = await db.execute(
sql
SELECT * FROM ${table} WHERE ${table.players}::jsonb ? ${slug}
SELECT * FROM ${table} WHERE ${table.players}::jsonb ? ${slug}

);

I get this error:

ERROR: operator does not exist: jsonb ? record
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.

Any suggestions would be really helpful
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Drizzle failed to parse an empty JSONB Array
Drizzle TeamDTDrizzle Team / help
2y ago
array of number returning strings
Drizzle TeamDTDrizzle Team / help
2y ago
sql operator with array of strings
Drizzle TeamDTDrizzle Team / help
2y ago
malformed array literal when trying to insert a 2d array of strings
Drizzle TeamDTDrizzle Team / help
15mo ago