There is table1 (is, surename) , table2(id, reporter,assign)

reporter and assign at table2 refer to Id in table1. As a result, you need to make a selection of all the records of table2, excluding duplicate duplicates, for example reporter=2 , assigne=1 should not be duplicated as assigne=2 , reporter=1

    2 answers 2

    I do not really understand why in task table1 , if the task is:

    As a result, you need to make a selection of all records table2

    Which can be done by request:

     select distinct t1.* from test t1 where not exists (select * from test t2 where t2.reporter = t1.assign and t2.assign = t1.reporter and t2.reporter > t1.reporter and t2.assign < t1.assign) 

    sqlfiddle

      If you need only unique combinations, you can do this:

       select distinct case when reporter > assign then assign else reporter end, case when reporter > assign then reporter else assign end from table2