M
M
mark_me2019-10-04 14:16:50
SQL
mark_me, 2019-10-04 14:16:50

How to do a join in one SQL query?

Table users:
id | login
Table messages:
id | sender_id | receiver_id | text | date
How to make in one request, through INNER JOIN connection, so that in the end it turns out to make a selection from 2 users (sender and recipient). At the moment, here is a request that receives only the sender's login:

SELECT * FROM users INNER JOIN messages ON users.id = messages.sender_id

As a result, I want to get 2 logins, by sender_id and receiver_id

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
d-stream, 2019-10-04
@mark_me

inner join table_name as table_1 on table_1 . ...
inner join table_name as table_2 on table_2 . ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question