Heh guys,
I need help with a MySQL Query. The Output of the query should look like this
User1 User2
xxx1 xxx2
xxx3 xxx1
but not
User1 User2
xxx1 xxx2
xxx2 xxx1
and so on.
I need all "friendships" between different users. A friendship exists i.e. when
UserId 8 exists in Column User1_id
UserId 4 exists in Column User2_id
**AND**
UserId 8 exists in Column User2_id
UserId 4 exists in Column User1_id
Thanks in Advance!
Friendship Table
+----------+----------+
| User1_id | User2_id |
+----------+----------+
| 8 | 4 |
| 4 | 8 |
| 29 | 4 |
| 4 | 10 |
| 10 | 4 |
| 8 | 37 |
| 4 | 29 |
| 37 | 8 |
| 37 | 4 |
| 29 | 8 |
| 4 | 37 |
| 8 | 10 |
| 8 | 29 |
| 4 | 40 |
| 40 | 4 |
| 40 | 29 |
| 29 | 40 |
+----------+----------+
User Table
+----+-----------------------------+
| id | username |
+----+-----------------------------+
| 4 | hhessel |
| 8 | xxx1 |
| 10 | xxx2 |
| 29 | xxx3 |
| 40 | xxx4 |
| 37 | xxx5 |
| 39 | xxx6 |
+----+-----------------------------+