Sqlite-我已经选择了,如何更新这些记录?

时间:2017-02-04 03:55:13

标签: python-2.7 sqlite

我的select语句找到我想要更新的记录 - 现在我想要反转(乘以x -1)仅适用于这些记录的adjusted_sentiment得分。这是select语句:

Select  players.name, fbposts.company,  fbposts.post_id, reactions.reaction, 
fbposts_comments.adjusted_sentiment, fbposts_comments.message, fbposts.message from fbposts
join reactions on reactions.post_id = fbposts.post_id
join players on players.id = reactions.id
join fbposts_comments on fbposts_comments.post_id = fbposts.post_id
where adjusted_sentiment > 0 and reactions.reaction like "ANGRY" and 
reactions.id = fbposts_comments.comment_id group by fbposts.post_id

这会返回如下记录:

Baktiyar Romanov,WorldOfWanderlust,387990201279405_994067924004960,ANGRY,0.5965,probably fed very ill-mannered rich man
Sheridan Toms,australiapost,96085205666_10153485650690667,ANGRY,0.04676666666666666,Seriously? You can't even get an express post parcel from victoria to wa in under 2 weeks!!!! Super annoyed  
Robert Smissen,australiapost,96085205666_10153487649895667,ANGRY,0.8555,Looks like Australia Post is using Diggers' letters to gain some reflected glory
Eve Ismaiel,australiapost,96085205666_10153500759100667,ANGRY,0.1133333333333333,"Ha ha... Present $20, postage $30!!!" 

我想要做的是颠倒adjust_sentiment得分。例如,在第一条记录中,adjust_sentiment得分为0.5965我想将其更新为-0.5965

顺便说一句,我的查询和更新将通过Python2.7完成......我现在正在研究的是从上面的查询创建一个列表,然后使用该列表创建一系列更新语句。

1 个答案:

答案 0 :(得分:-1)

willDisplay cell