Database Reference
In-Depth Information
Looking up a specific status update
In our status update application, we'll want to allow direct linking to status updates, in
which case we'll need to be able to retrieve a specific status update from the table. So far,
we've issued an open-ended
SELECT
statement to see all the rows we've inserted in
user_status_updates
, but we haven't seen how to return one particular row.
Since
user_status_updates
has a compound primary key, we need new CQL syntax
to allow us to specify values for multiple columns in order to form a unique identifier. CQL
provides the
AND
construct for this purpose:
SELECT * FROM "user_status_updates"
WHERE "username" = 'alice'
AND "id" = 76e7a4d0-e796-11e3-90ce-5f98e903bf02;
By specifying both the
username
and the
id
, we identify exactly one row:
We now have all the tools we need to interact with the
user_status_updates
table in
the same way as we interact with the
users
table; let's move on and explore some of the
things that make a compound primary key table different.