I have a table called, group, and another table called member. group has fields of groupId, name, etc... member has fields of memberId, groupId, memberName, etc... where groupId is being a foreign key to group table. I want to query these two table in a single statement such that the result outputs as follows.
[
{
"groupId": "8",
"name": "Test Group 2",
"status": "0",
"member": [
{
"memberId": "1",
"groupId": "8",
"memberName": "tester 1"
}
]
}
]
I have looked into INNER JOIN and UNION but couldn't figure out how to achieve this. Any advice would be helpful. Thank you.