我有两张桌子:
users(userid, username)
和
cases(cid,assign_to,received_by)
我想加入assign_to
和
received_by
user_id
并生成username
username
。
我如何加入这些表格以及我如何加入
生成assign_to
到received_by
和
assign_to
?
这两个字段received_by
和
userid
存储不同
> eg assign_to received_by
> 1 3
> 2 4
。
username
我想在这些字段中生成{{1}}。
答案 0 :(得分:2)
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
以下是此目的的基本联接