E
E
Egor Mikheev2017-08-10 15:51:44
MySQL
Egor Mikheev, 2017-08-10 15:51:44

How to cross join 2 columns of the same field in 1 table?

There is a table of correspondence of friends
--------------------------------------
idUser | IdfriendUser | dateadd |
--------------------------------------
1 | 2 | date |
2 | 3 | date |
--------------------------------------
how to get a table that duplicates a friend's field in a user field and a field user in friend field
--------------------------------------
idUser | IdfriendUser | dateadd |
--------------------------------------
1 | 2 | date |
2 | 1 | date |
2 | 3 | date |
3 | 2 | date |
--------------------------------------
and is it even worth doing it this way?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Artyom Tokarevsky, 2017-08-10
@artemt

Whether or not you need to decide. In principle, it can be convenient for various associations.
You can hang on the table triggers for adding and deleting records that will add or delete a mirror record.

H
heartdevil, 2017-08-10
@heartdevil

And why do you need it?
Try cross join

C
Coffin, 2017-08-10
@Coffin

Better tell me what task, maybe you don't need it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question