Answer the question
In order to leave comments, you need to log in
How to get combined data from two tables in a database in JSON?
There is a table of posts: id, title, url
There is a table of links in posts: id, link, post_id (id from the first table, the post in which the link is)
You need to get information about posts in the output in this form:
[ {id, title, url, links: [{link1},{link2},{link3}]}, {id, title, url, links: [{link1},{link2},{link3}]}, {id, title, url, links: [{link1},{link2},{link3}]} ]
How to do it with tricky SQL query, two simple queries + php processing?
There are several thousand records in both tables.
Tell me where to dig) First of all, how it is correctly called.
Answer the question
In order to leave comments, you need to log in
if there is a limit on the number of links in one post, then you can collect data with a simple join + group_concat, which, in three lines, then in puff, bring it to the form you need
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question