EDIT: I’m using MySQL, InnoDB.
I have some trouble with the below:
My tables are user, user_matrix, user_parts.
user:
id, username
user_matrix:
userid, partcode
user_parts:
id, label, partcode
What I’m trying to do is join these into a single query, where the following data:
user:
1, zenph
user_matrix:
1, abc
1, def
1, ghi
user_parts
1, arms, abc
2, legs, def
3, head, ghi
..results in a user, with the parts as the array for each row. Is this possible? I’ve tried but I keep retuning a single user_parts row per user row. I need the entire related rows. The output should be:
1, zenph, array(
array(1,arms,abc),
array(2,legs,def),
array(3,head,ghi)
)
Appreciate ANY help. I’m currently reading up what I can but I just can’t get my head around this particular situation.
This would likely necessitate using a cursor to loop through the parts and add them to an array/delimited string. We would need to know what DBMS you are using to provide any code examples.