I have table in this format with more rows:
res_id quiz_id sender_id user_id answer_id answer points
1 115 10 13 45 75 1
2 115 10 13 46 79 1
3 115 10 13 47 83 0
4 118 1 3 51 90 0
5 118 1 3 51 90 0
6 115 10 13 45 75 1
I want to get results in php this way: If sender_id=10 and qui开发者_Go百科z_id > 3 (means if 115 is there 3 times or more) look for points (if points has three corresponding values of 1) return 1 else 0
In above example above i should get back 1 as quiz_id 115 is used more than 3 times and points have at least 3 corresponding values of 1
For below table i should get 0
res_id quiz_id sender_id user_id answer_id answer points
1 115 10 13 45 75 1
2 115 10 13 46 79 1
3 115 10 13 47 83 0
Can any one help me with this query?
try something like
SELECT quiz_id , SUM(points) AS summe FROM mytable
WHERE sender_id = 10
GROUP BY quiz_id
HAVING summe > 2
精彩评论