Assume 2 tables:
TABLE: team
-----------
| team_id |
===========
| 1 |
-----------
| 2 |
-----------
TABLE: team_member
-------------------------------------------
| team_member_id | team_id | age | gender |
===========================================
| 1 | 1 | 20 | Male |
-------------------------------------------
| 1 | 2 | 25 | Male |
-------------------------------------------
| 1 | 2 | 23 | Female |
-------------------------------------------
How do I search for things like this:
- List of all teams that are only male, between ages of 18 and 25.
- List of all teams that are male and female, where either gender is between ages of 18 and 25.
- Etc.
I’m basically looking for general strategies on how to apply certain filters (e.g. age) across all the children records of team. Suggestions?
team, team_member
You can’t just apply a simple WHERE clause if you are checking for only an all male or all female team… it needs to be compared against the full set of team members. Try
Similarly, to ensure you have BOTH male AND female…