L
L
LightSid2016-11-06 01:23:45
PHP
LightSid, 2016-11-06 01:23:45

How to get json from two tables in database?

Let's say there is a database that has two tables 'author' and 'books'.
the 'books' table has the fields 'title' and 'author_id'.
You need to get json like:

{"title": "Book title", "name": "Author's name"}

Please tell me how to do it right.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Sisyukin, 2016-11-06
@Caarl

Select * from avtor a, book b where b.autor_id=a.id
Neither and then collect the array and do json_encode

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question