Question : MySQL Three Table Join Query

This is a follow-up to another question I asked:
http://www.experts-exchange.com/Database/MySQL/Q_26413652.html

The answer there was good and helpful.  But what I really need is this...

I have a table for users
I have a table for trades
I have a table for tags

The trades table has (among others) the fields:

TRADES
- trade_id
- originator_tag_id
- partner_tag_id
- partner_user_id
- originator_user_id

then there is a tags table like this:

TAGS
- tag_id
- serial_number

then the user table is like this:

USERS
- user_id
- username

I got an answer on how to pull in the serial_number from TAGS with a query about TRADES for each of the tags.  It is in the code section below but can also be viewed at the question link above.

Now, I'd like to extend this and add the names of the trade originator and trade partner to my results.  I've been poking at this on my own but it clearly exceeds my sql talents so I'm going to post this follow up and give the original answerers a chance to (hopefully) easily earn some more points.

Thanks in advance for any help!
1:
2:
3:
4:
SELECT t.*, ot.serial_number as ot_serial, pt.serial_number as pt_serial
FROM TRADES t
left join TAGS ot on ot.tag_id = t.originator_tag_id
left join TAGS pt on pt.tag_id = t.partner_tag_id

Answer : MySQL Three Table Join Query

this should do:
1:
2:
3:
4:
5:
6:
7:
8:
SELECT t.*, ot.serial_number as ot_serial, pt.serial_number as pt_serial
, ou.username originator_name
, pu.username partner_name
FROM TRADES t
left join TAGS ot on ot.tag_id = t.originator_tag_id
left join TAGS pt on pt.tag_id = t.partner_tag_id
left join USERS ou on ou.user_id = t.originator_user_id
left join USERS pu on pu.user_id = t.partner_user_id
Random Solutions  
 
programming4us programming4us