Solution skill
Is the OR operator supported in ScyllaDB?
Complete solution
Shows how to fix is the OR operator supported in ScyllaDB?. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
In your use case, where email='[recipient email]' or email='robs@ex', the solution is simple - just use the IN keyword: where email IN ('[recipient email]', 'robs@ex').
Steps
- CQL (the Cassandra Query Language, also implemented by ScyllaDB), does not have a general-purpose "OR" keyword (see issue #12910 - only "AND" is supported). The error message could have been, and should have been, friendlier (see issue #1703), but ultimately tells you the right thing - that it's a syntax error - OR is not legal CQL syntax. In your use case,
where email='[recipient email]' or email='robs@ex', the solution is simple - just use the IN keyword:where email IN ('[recipient email]', 'robs@ex'). By the way, the1=1part also doesn't work, not even without OR, because currently CQL expressions are rather limited in their scope, in this casecolumn=valueis a valid expression, butvalue=valueor other stuff, is not. Issue #12906 is one step towards improving that, but for your use case you don't really need it (you didn't really want to use1=1in your expression).
2. However if I use two conditions using OR operator it is giving syntax error. Even a simple 1=1...
## When to use
You are seeing this: CQL (the Cassandra Query Language, also implemented by ScyllaDB), does not have a general-purpose "OR" keyword (see issue #12910 - only "AND" is supported). Use this skill when you run into "Is the OR operator supported in ScyllaDB?".
## When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
## Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
## Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
Source: Stack Overflow #75832433 (accepted answer, 6 votes): How does OR condition works in WHERE clause for SELECT statements in scylladb. I have created secondary index on email. Below query works fine and return result. `` cqlsh> select * from test.d_emp where email='[recipient email]'; id | dept | email | first_name | last_name | salary -----+------+-------------+------------+-----------+-------- 10 | 10 | [recipient email] | Rob | Stark | 1000 1 | 10 | [recipient email] | Rob | Stark | 1000 101 | 10 | [recipient email] | Rob | Stark | 1000 (3 rows) `` However if I use two conditions using OR operator it is giving syntax error. Even a simple 1=1...
Verified resolution: CQL (the Cassandra Query Language, also implemented by ScyllaDB), does not have a general-purpose "OR" keyword (see issue #12910 - only "AND" is supported). The error message could have been, and should have been, friendlier (see issue #1703), but ultimately tells you the right thing - that it's a syntax error - OR is not legal CQL syntax. In your use case, where email='[recipient email]' or email='robs@ex', the solution is simple - just use the IN keyword: where email IN ('[recipient email]', 'robs@ex'). By the way, the 1=1 part also doesn't work, not even without OR, because currently CQL expressions are rather limited in their scope, in this case column=value is a valid expression, but value=value or other stuff, is not. Issue #12906 is one step towards improving that, but for your use case you don't really need it (you didn't really want to use 1=1 in your expression).
Source URL: https://stackoverflow.com/questions/75832433/is-the-or-operator-supported-in-scylladb
By @issueatlas · Version 3 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_NQZ5fIBhEFXuXiO4V5iboQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Is the OR operator supported in ScyllaDB? <span>— Vectle</span></a>