I have create table user in cassandra
create table users (pcId int , userId int, friendId int, age int, score int , name text, PRIMARY KEY (pcId, userId, friendId, score))
and I insert data:
INSERT INTO users(pcid , userid , score , friendid , age , name) Values (1, 1, 2, 1, 12, 'l');
INSERT INTO users(pcid , userid , score , friendid , age , name) Values (1, 1, 2, 2, 12, 'a');
INSERT INTO users(pcid , userid , score , friendid , age , name) Values (1, 1, 2, 0, 15, 'p');
INSERT INTO users(pcid , userid , score , friendid , age , name) Values (1, 2, 6, 1, 15, 'p');
INSERT INTO users(pcid , userid , score , friendid , age , name) Values (1, 2, 7, 2, 15, 'p');
pcid | userid | friendid | score | age | name
1 | 1 | 0 | 2 | 15 | p
1 | 1 | 1 | 2 | 12 | l
1 | 1 | 2 | 2 | 12 | a
1 | 2 | 1 | 6 | 15 | p
1 | 2 | 2 | 7 | 15 | p
My question is: How can I select for every userid 2 friends(friendid, age, name, score) sorted by name?
My result should be:
pcid | userid | friendid | score | age | name
1 | 1 | 2 | 2 | 12 | a
1 | 1 | 1 | 2 | 12 | l
1 | 2 | 1 | 6 | 15 | p
1 | 2 | 2 | 7 | 15 | p