There is a friend matching table

-------------------------------- idUser | IdfriendUser | DateAdd | -------------------------------- 1 | 2 | date | --------------------------------- 2 | 3 | date | --------------------------------- 

how to get a table that duplicates a friend field in a user field and a user field in a friend field

 ------------------------------------ idUser | IdfriendUser | DateAdd | ------------------------------------ 1 | 2 | date | ------------------------------------ 2 | 1 | date | ------------------------------------ 2 | 3 | date | ------------------------------------ 3 | 2 | date | ------------------------------------ 

and is it worth doing it this way?

  • 2
    select A, B from table union select B,A from table . And whether it is worth doing or not is up to you, it all depends on the task for which you need such a sample - Mike

1 answer 1

 select idUser, IdfriendUser, DateAdd from table union select IdfriendUser, idUser, DateAdd from table