Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
RalphB
Starting Member
2 Posts |
Posted - 2008-09-30 : 12:06:27
|
| I am going to simplify my question in the hopes someone helps me with something I am trying to accomplish.I have two tables. One table contains a unique user id and a user name.The other table contains a recipient id, sender id, and a message.Both the recipient id and sender id represent a username in the first table.In a single SELECT statement, I want to get a single record row that contains the sender id, sender id name, recipient id, recipient id name, and the message (as five column data). What is the best way to do this? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-09-30 : 12:36:16
|
| [code]SELECT t1.sender_id,t3.user_name as [sender name],t1.recipient_id,t2.user_name as [recipient name],t1.messageFROM Table1 t1JOIN Table2 t2ON t2.user_id=t1.recipient_idJOIN Table2 t3ON t3.user_id=t1.sender_id[/code] |
 |
|
|
RalphB
Starting Member
2 Posts |
Posted - 2008-09-30 : 13:24:55
|
| Thank you, that is perfect guidance. |
 |
|
|
|
|
|