Cassandra Limit 10,20条款
问题描述:
我使用的是Cassandra 1.2.3,可以使用Limit 10执行select查询。
I am using Cassandra 1.2.3 and can execute select query with Limit 10.
如果我想要10到20的记录, 20。
If I want records from 10 to 20, I cannot do "Limit 10,20".
以下查询给我一个错误。
Below query gives me an error.
select * from page_view_counts limit 10,20
如何实现?
感谢
Nikhil
Thanks Nikhil
答
你不能在CQL中跳过。您必须通过指定开始位置进行分页例如
You can't do skips like this in CQL. You have have to do paging by specifying a start place e.g.
select * from page_view_counts where field >= 'x' limit 10;
以获取从x开始的接下来的10个元素。
to get the next 10 elements starting from x.
我在这个答案中写了一个完整的例子: Cassandra分页:如何使用get_slice从Python使用cql库查询Cassandra 1.2数据库。
I wrote a full example in this answer: Cassandra pagination: How to use get_slice to query a Cassandra 1.2 database from Python using the cql library.