簡體   English   中英

如何統計某個狀態和某個user_id的通知?

[英]How to count notifications with a certain status and a certain user_id?

enter image description here如何計算具有特定狀態和特定 user_id 的通知? 我在通知表中有一些數據,如何根據user_id 2計算狀態為字段3的通知的邏輯? 我想發出總共 3 條通知,其中 status 字段為 3 in user_id 2

您正在搜索 function 的群組。

對於所有用戶和狀態:

SELECT COUNT(user_id), user_id, status FROM {Insert your table name} GROUP BY user_id, status ORDER BY user_id ASC;
calculate notification whose status is field 3 based on user_id 2

根據你的要求,where條件是基於user_id 2的狀態字段3。

所以你可以這樣做

SELECT COUNT(*) FROM tablename WHERE status = 3 AND user_id = 2

下次請向我們展示你的努力。 謝謝

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM