I have database like this:
+-----+---------+--------------+
| id | user_id | form_answers |
+-----+---------+--------------+
| 1 | 1 | yes |
| 2 | 1 | M |
| 3 | 2 | yes |
| 4 | 2 | M |
| 5 | 3 | no |
| 6 | 3 | F |
| 7 | 4 | no |
| 8 | 4 | M |
+-----+---------+--------------+
There was a form that inserted to this database . It had one question and dropdown list (male of female). Is it possible to count how many “yes” answers the male (M) users gave? It doesn’t have to be counted…it can just select of all rows with answer “yes” from male users.
You can join answers tabe with itself. This will return the list of “yes” answers male users gave:
to count the rows, just substitute the select line with this:
see fiddle here.