-1
我需要填補這一變量對給定action_to(包含用戶ID)
type_1_count = "select count(action_type) from action where action_type = 1 AND user_from = 13213"
type_2_count = "select count(action_type) from action where action_type = 2 AND user_from = 13213"
type_3_count = "select count(action_type) from action where action_type = 3 AND user_from = 13213"
或
$type_counts = "three count sub queries in single query"
通常我們,'三計數查詢'或'三國單個查詢'中的子查詢。
有沒有更好的方法,我可以在單個查詢中獲取動作類型的計數?
'SUM'是否可以作爲划船計數法使用? – 2014-12-13 13:47:14
@SamuelCook。 。 。當然。 'sum(1)'和'count(*)'做同樣的事情。 – 2014-12-13 13:47:56
但是如果'action_type' = 3會怎麼樣?每行不會被計算3次? – 2014-12-13 13:49:27