Database Reference
In-Depth Information
Reading a collection column from multiple rows
Suppose we'd like to retrieve a handful of status updates from the database and display in-
formation about them, including who starred them. Naïvely, we might expect to be able to
perform a query of this form:
SELECT * FROM "user_status_updates"
WHERE "username" = 'alice'
AND "id" IN (
3f9b5f00-e8f7-11e3-9211-5f98e903bf02,
3f9b5f00-e8f7-11e3-9211-5f98e903bf02
);
However, if we perform this query, we'll see an error:
One limitation of Cassandra collections is that you cannot read collections when selecting
multiple rows using a WHERE…IN clause. Once you have collection columns in your table,
you must explicitly select only noncollection columns when using WHERE…IN .
On the other hand, it's entirely legal to read collection columns when retrieving multiple
rows via a range of clustering columns:
SELECT * FROM "user_status_updates"
WHERE "username" = 'alice'
ORDER BY "id" ASC
LIMIT 2;
This query completes successfully and displays the data from the collection columns:
Search WWH ::




Custom Search