我目前有当前的查询:
SELECT count(*) as number_of_items,
if(first_name <> "", 1, 0)
+ if(last_name <> "", 1, 0)
+ if(current_avatar is not null, 1, 0)
+ if(username <> ""
AND email <> ""
AND gender <> ""
AND date_of_birth <> "" ,1,0) AS completeness
FROM `user` HAVING (completeness = '4')
但这并没有按预期工作。似乎它们的完整性都为 2。如果我删除计数和有子句,它确实会看到所有不同的完整性计数(从 1 到 4)。有没有办法计算个人的完整性计数?