我可以为以下条件编写查询吗?
if (online_member == 0) {
offline_member = offline_member + 1;
} else {
online_member = online_member + 1;
}
我的查询:
SELECT `name`,
SUM(IF(online_member =0, 1, 0)) AS offline_member,
SUM(IF(online_member =1, 1, 0)) AS online_member
FROM members
有没有更好的方法来编写上述查询?