I have a design problem with SQL request:
I need to return data looking like:
listChannels:
-idChannel
name
listItems:
-data
-data
-idChannel
name
listItems:
-data
-data
The solution I have now is to send a first request: *"SELECT * FROM Channel WHERE idUser = ..."* and then in the loop fetching the result, I send for each raw another request to feel the nested list: "SELECT data FROM Item WHERE idChannel = ..." It's going to kill the app and obviously not the way to go.
I know how to use the join keyword, but it's not exactly what I want as it would return a row for each data of each listChannels with all the information of the channels.
How to solve this common problem in a clean and efficient way ?
NoSQL database.ParentIdChannelcolumn, then use that to construct the tree in the calling code (C#, PHP etc). The select statement you use to return the relevant nodes depends on which database engine you are using (MySQL, SQL Server), so add the relevant tag for it to the question and we may be able to help you with it.