Getting join data back as an array #1161
-
I'm sure this is simple but I have a table of USERS and each user can have multiple NOTES so I'm doing:
It is returning the rows fine but it's coming back with multiple rows for each user that have multiple notes and just a single row for users with no notes (or a single note). How can I get a single row for each user and the notes for users embedded as an array? I'd like to loop over the users on my front-end and inside that loop, loop over the notes for said user. Should I do two DB calls and join this as JSON myself with JS or what is the best practice for something like this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This isn’t a forum for general SQL support. Go to stack overflow and look for “group_concat.” https://www.sqlite.org/lang_aggfunc.html#group_concat Edit: apologies for the terseness--I replied on GitHub mobile, and thought this was an Issue, not a Q&A discussion post! |
Beta Was this translation helpful? Give feedback.
This isn’t a forum for general SQL support. Go to stack overflow and look for “group_concat.”
https://www.sqlite.org/lang_aggfunc.html#group_concat
Edit: apologies for the terseness--I replied on GitHub mobile, and thought this was an Issue, not a Q&A discussion post!