There is a table t1 in which data is stored: name, time, etc.

 id |  name 
 1 |  data 1
 2 |  data 2
 3 |  data 3

There is a second table t2 in which there is a connection.

 id |  t1_id_1 |  t1_id_2
 1 |  1 |  2
 2 |  1 |  3

I need to get that answer.

 1 - data 1 \ data 2
 2 - data 1 \ data 3

How to perform such a request? Can generally change the structure of the table?

    1 answer 1

    This is a normal structure. Is it only to remove the id field from the link table as unnecessary. A pair of entity references is a great natural primary key.

    The trick is only to double down the table and assign different aliases:

    select t2.id, t1_1.name, t1_2.name from t2 join t1 as t1_1 on t1_1.id=t1_id_1 join t2 as t1_2 on t1_2.id=t2_id_1