I have two tables and I would like to join them. Below there are the examples of tables and the result table:
Table A
ID | PLACE | R_ID | M_ID |
---|---|---|---|
1 | PLACE_1 | 51 | 53 |
2 | PLACE_2 | 52 | 54 |
Table B
S_ID | NAME |
---|---|
51 | A |
52 | B |
53 | C |
54 | D |
Output Table
ID | PLACE | R_NAME | M_NAME |
---|---|---|---|
1 | PLACE_1 | A | C |
2 | PLACE_2 | B | D |
I tried query:
SELECT
id,
place,
name as r_name
FROM
table_a
LEFT JOIN table_b ON r_id = s_id
Query result
ID | PLACE | R_NAME |
---|---|---|
1 | PLACE_1 | A |
2 | PLACE_2 | B |
But I don't know how to join next column m_name.