我想计算一些列,但我的查询计数不正确。
SELECT COUNT(*) AS zero_count FROM messages WHERE uid_fk = '$uid' AND uploads IS NOT NULL AND uploads <>'' AND option = '1'
计数上传值,如果上传的值不为空,并检查选项=“1”
所以如果上传值不为空,并选择= 1,那么指望它。
例如:
uid_fk uploads option
1 75, 0 Not counting because secret_option is 0
1 76,77, 1 Count because it is 1 and upload value is not empty
1 1 Not count because upload value is empty
1 78, 1 Count because it is 1 and upload value is not empty
1 1 Not count because upload value is empty
1 79,80, 0 Not count because option is 0
我查询计数所有选项= 1只,但它需要数:
如果上传的值不为空,并选择是1,那么指望它。
什么我需要做的查询计数上传不空和选项= 1任何人都可以在这方面帮助我?
+0
您是在计数行还是在上传列中添加值? –
+0
@robert我想计数,如果上传值不为空,选项= 1。 –
+0
你需要什么SUM或COUNT? –