Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search an array element in SurrealDB

Tags:

surrealdb

I'm trying to perform a query that evaluates if an array includes or contains a specif value or set of values.

SELECT * FROM table WHERE data = ['value_a']

https://surrealdb.com/docs/surrealql/statements/select

I've read the documentation and try several queries, but I didn't find any function or way to create this query.

I've read the official documentation and performed several queries based on the examples, but nothing have worked.

https://surrealdb.com/docs/surrealql/statements/select

My expected behaviour is:

Matches a specific value or set of values like these examples in SQL relational database.

https://www.w3schools.com/sql/sql_in.asp

like image 277
codesandtags Avatar asked Nov 30 '25 11:11

codesandtags


1 Answers

There is a CONTAINS operator : https://surrealdb.com/docs/surrealql/operators#contains

The Query should be like:

SELECT * FROM table WHERE data CONTAINS 'value_a'
like image 151
Fabian Avatar answered Dec 08 '25 22:12

Fabian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!