I have got a problem and I am trying to, but I can’t get it to work.
I have got the following table:
messages
|-------------|----------------|
| senderID | recipientID |
|-------------|----------------|
| 4 | 3 |
| 3 | 4 |
| 3 | 423 |
| 18 | 4 |
| 391 | 4 |
| 4 | 19 |
| 3 | 4 |
| 48 | 213 |
| and so | on ... |
|-------------|----------------|
Now, I want to get a list of the threads, that means: A list of all persons I wrote messages with. So the problem is, that I have to look that either in the column “senderID” or “recipientID” is my userID (wich is, in this example, 4) and that I “erase” duplicate entries (so I don’t have 2 entries with the other user having the id “3” for example).
I have tried some very strange things with JOIN and GROUP BY, but didn’t get it to work.
May somebody please help me?
Best greetings,
SargTeX
In the first clause, using distinct means that each recipient will appear only once; the same is true of the second clause, and using union means that only values distinct to both clauses will appear.