[FONT=courier new]Hi
I'm trying to write a simple messaging system using the following table designs (they have been simplified to aid
explanation).
Users table:
| ID | Name |
|-----+--------+
| 1 | Joe |
| 2 | Andy |
| 3 | Liz |
| 4 | Jen |
Messages table:
| Mail ID | Date Sent | To | From | Subject |
+---------+-----------+----+------+------------------------------------+
| 1 | 20040601 | 1 | 3 | Hello
| 2 | 20040602 | 3 | 1 | Re: Hello
| 3 | 20040602 | 4 | 3 | Have just spoken to Joe!
How do I write a query that produces the following data:
| Mail ID | Date Sent | ToName | FromName | Subject |
+---------+-----------+--------+----------+------------------------------------+
| 1 | 20040601 | Joe | Liz | Hello
| 2 | 20040602 | Liz | Joe | Re: Hello
| 3 | 20040602 | Jen | Liz | Have just spoken to Joe!
I can get one of the names in the outputted data using an INNER JOIN, but cannot see how to get both.
Any help would be much appriciated....
Thanks,
Joe
[/FONT]