tags:

views:

102

answers:

1

I have two tables:

users(userid, username)

and

cases(cid,assign_to,received_by)

I want to join assign_to and received_by with user_id and produce username.

How do I join these table and how I produce username to assign_to and received_by?

These two fields assign_to and received_by are stored different userid.

> eg assign_to                      received_by
>      1                                   3
>      2                                   4

I want to produce username in these fields.

+2  A: 

select u1.* from Users as u1
join Cases as c1
on u1.userid = c1.received_by
join cases as c2
on u1.userid = c2.assign_to


Here is basic join for the purpose

Saar