M
M
Maxim Zolotoy2018-03-09 17:32:09
SQL
Maxim Zolotoy, 2018-03-09 17:32:09

How to make such sql query from multiple tables?

It has a table with user data, as well as a second table with photos of these users.
The id from the first table is linked to the user_id field from the second table. How to write one query that will take all the data of all users from the first table and also hook the name (photo_name field) of the photo from the second table that matches the user?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2018-03-09
@demon416nds

join to help

D
Denis, 2018-03-09
@sidni

select u.*,ui.photo_name
from users as u
left join users_info as ui on u.user_id = ui.user_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question