sqlcassandrapycassa

Is there any query for Cassandra as same as SQL:LIKE Condition?


The LIKE condition allows us to use wildcards in the where clause of an SQL statement. This allows us to perform pattern matching. The LIKE condition can be used in any valid SQL statement - select, insert, update, or delete. Like this

SELECT * FROM users
WHERE user_name like 'babu%';

like the same above operation any query is available for Cassandra in CLI.


Solution

  • Simple answer: there is no equivalent of LIKE

    https://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlSelect.html

    Here is the command reference for v0.8:

    http://www.datastax.com/docs/0.8/references/cql#cql-reference

    If you maintain another set of rows that hold references to a username:

    row: username:bab -> col:babu1, col:babar row: username:babu -> col:babur

    Effectively you are cheating by pre-populating all of the results that you would normally search with in the RDBMS world. Storage is cheap in comparison to what it was years ago ... which is why this is now an accepted approach. It's less intensive on the CPU and Memory to retrieve a pre-populated list of information.