0
I have a table called area with the structure:
Id, Nome, Status
I have another table called news with the structure:
Id,Título,Descricao,Data,IdArea,Status
I would like to return all news records grouped by area code, where the result would be grouped by Area Id, and list N news.
Format of the desired result:
[Id Área]
[idNoticia],[título],[descricao]
[idNoticia],[título],[descricao]
[idNoticia],[título],[descricao]
[...]
[...]
I want to see the possibility of the return being directly the database, without interaction with php for example. See if it is feasible or not too.
– lelopes
In your question it is not clear the need to format the result of the database, but it is not possible, there is no way to make queries that return multidimensional arrays
– Costamilam
so in case you want to return all records of the table news for all areas, in case I will have to do more than one query to bd to be able to receive the data and manipulate them in php for example. The idea is to group all news by area, so you could manipulate the data better.
– lelopes
I guess I didn’t get it, I could explain it better?
– Costamilam
worth, gave to understand his answer, is that wanted to sweep the table Area, and return grouped by Id of the area all the corresponding news, but wanted in a multidimencional array not to need to make n queries in the bank and return separately for each Idarea
– lelopes
In general you will hardly need to perform more than one query to show the data, but you may need to format, as in this case. One remark, this type of formatting is preferable to do on the frontend, to relieve the server
– Costamilam