April 2017
Beginner to intermediate
360 pages
9h 35m
English
While, in some cases, it might be fine to simply keep requesting pages until no more records are encountered, it's often nice to give the user a sense of how many records they're dealing with up front. Happily, we can use the COUNT function to do just this:
SELECT COUNT(1) FROM "user_status_updates"WHERE "username" = 'alice';
Instead of requesting a list of columns or a wildcard to get all columns, we select COUNT(1) to get a total count of rows matching the WHERE condition:

We could have also used COUNT(*), which behaves in the same way as COUNT(1). There are, however, no other valid ways to use the COUNT function in CQL. ...
Read now
Unlock full access