Answer the question
In order to leave comments, you need to log in
How to build a SELECT query combined from two tables?
The first table is something like news
columns id | owner_id | subject
Second table users
id | Nick | photo_res
Through a cycle I sort through it and I deduce in html. It is necessary that the user himself is also selected in the search, that is, owner_id is the id from the second table. You can't make a separate request.
Answer the question
In order to leave comments, you need to log in
use join
like this:
SELECT * FROM table1
LEFT JOIN table2 ON table1.owner_id = table2.id
SELECT t1.poster_id, t1.subject, t1.time, t2.id, t2.name, t2.second_name FROM adverts AS t1, people AS t2 WHERE t1.poster_id=t2.id GROUP BY t1.poster_id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question