This question has already been answered:

There are 2 tables: users and objects . users store id, name, type , etc. In objects , id, user_id , etc. are stored. Question: how to make a selection of all values ​​in the objects table in one objects , where type in users is, for example, 2

Marked as a duplicate by the participants Sergey Gornostaev , aleksandr barakin , Bald , user194374, Alex 27 Dec '16 at 12:40 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • one
    inner join and where by type = 2 - Mike

1 answer 1

 SELECT o.id, o.user_id FROM objects AS o INNER JOIN users AS u ON o.user_id = u.id WHERE u.type = 2 
  • In this case, the first row in the object table is selected. And how to choose all the lines? - Ruslan
  • Get out - all. Most likely, you are watching a tool that shows only one record. - Akina
  • all figured out! thanks - Ruslan