2

How can I skip first few rows in the resultset in cqlsh? I know I can iterate the resultset and ignore first few rows, but I am looking to do it in the query itself.

Following queries work in SQL, but what is their equivalent in cqlsh

      SELECT * FROM foo LIMIT 10, 50
      SELECT column FROM table LIMIT 10 OFFSET 10

I looked up QueryBuilder (and related classes in DataStax) and didnot find anything there. Thanks

mobileDev
  • 1,358
  • 2
  • 14
  • 34
  • 2
    possible duplicate of [Results pagination in Cassandra (CQL)](http://stackoverflow.com/questions/26757287/results-pagination-in-cassandra-cql) – piotrwest Aug 13 '15 at 17:06

1 Answers1

2

As far as I know, CQL does not currently include support for a starting offset. The LIMIT clause only controls an upper bound and not a starting offset.

See the documentation here.

Probably your best bet would be to use tail and run cqlsh from bash like this:

cqlsh -e "SELECT ... LIMIT 10;" | tail -n+9

The value of 9 would skip the first 5 lines since there is a header for the column names you need to skip also.

If you are writing in java then of course you'd have other programmatic options.

Jim Meyer
  • 9,275
  • 1
  • 24
  • 49