chrisTina
chrisTina

Reputation: 2378

CQL select specific columns

For the following Cassandra schema:

CREATE TABLE periods (
period_name text,
event_name text,
event_date timestamp,
weak_race text,
strong_race text,
PRIMARY KEY (period_name, event_name, event_date)
);

Usually the select statement can be like:

SELECT * FROM ruling_stewards
WHERE king = 'Brego'
AND reign_start >= 2450
AND reign_start < 2500 ALLOW FILTERING;

But is there a way to select the specific columns without giving a relation? For example, to show all the event_name and period_name columns? (do not show other unmentioned columns).

Upvotes: 2

Views: 3557

Answers (1)

Aaron
Aaron

Reputation: 57808

Just as with SQL, to only show specific columns, you can name them in your SELECT statement:

SELECT event_name, period_name 
FROM ruling_stewards;

That works with or without specifying a WHERE clause.

For further reference, read through the Cassandra 2.x SELECT doc.

Upvotes: 5

Related Questions