2016-08-08 53 views
0

的更新值:卡桑德拉:我創造了這個表中的列集羣

CREATE TABLE postsbyuser(
    userid bigint, 
    posttime timestamp, 
    postid uuid, 
    postcontent text, 
    year bigint, 
    PRIMARY KEY ((userid,year), posttime) 
) WITH CLUSTERING ORDER BY (posttime DESC); 

我的查詢是讓所有用戶帖子在一年內由降序排序發表時間。 與排序是一切就OK了,但問題是,如果用戶編輯postcontent的發表時間將改爲:

update postsbyuser set postcontent='edited content' and posttime=edit_time where userid=id and year=year 

我得到的錯誤:[Invalid query] message="PRIMARY KEY part time found in SET part"

你有什麼想法如何訂購改變時間的帖子?

回答

-1

您應該在查詢中指定聚簇列。

update postsbyuser set postcontent='edited content' and posttime=edit_time where userid=id and year=year and posttime=previous_post_time 
+0

無法更新聚簇列中的值,因爲它屬於主鍵 – pratsJ