Hi, I'm trying to code a query that gets all the news and all the comments for each news. My current query is :
SELECT n.*,
c.* AS comments
FROM news n
JOIN comments c ON (c.news_id = n.id)
But when I fetch the query as an array it gives me a key by comment and I would like to have a key by news and all comments in a sub-array.
Something like:
Array
(
[0] => Array
(
[id] => 1 // news' id
... // rest of news' data
[comments] = Array
(
[id] => 1 // comment's id
... // rest of comments' data
)
),
... // all other news
)
Thanks!