0
考慮以下表計數已轉推
users tweets
--------------------------------- ---------------------------
user_id num_retweets sum_retweets tweet_id user_id retweeted
--------------------------------- ---------------------------
1 1 1 3
2 2 1 0
3 3 1 4
4 2 0
5 2 0
6 3 1
7 3 2
8 3 0
我想算num_retweets
:的次數一個用戶曾撰文指出,已轉推和sum_retweets
一轉推:中用戶推文全部轉發的次數。在UPDATE
查詢後預期users
表:
users
---------------------------------
user_id num_retweets sum_retweets
---------------------------------
1 2 7 <-- 3 + 4
2 0 0
3 2 3 <-- 1 + 2
建設這兩個查詢任何幫助將大大appreaciated :-)我一直有跨表進行UPDATE
的煩惱。
這很好。謝謝 :-) – Pr0no 2012-07-25 20:59:13