一个礼物表: from(赠送者) to(收到者)
一个用户表:id nickname
from和to都关联用户表的id,怎么查询出结果:
赠送者昵称 收到者昵称
回复内容:
一个礼物表: from(赠送者) to(收到者)
一个用户表:id nickname
from和to都关联用户本文来源gaodaimacom搞#^代%!码&网*
搞代gaodaima码
表的id,怎么查询出结果:
赠送者昵称 收到者昵称
<code>select *from 礼物left join 用户 as 发送方on 礼物.from =发送方.idleft join 用户 as 接受方on 礼物.to = 接收方.id</code>
其中的中文换成对应英文。。。字段自己处理一下
多对多的表连接查询
select usertable1.nickname, usertable2.nickname from gifttable left join usertable as usertable1 on usertable1.id = gifttable.from left join usertable as usertable2 on usertable2.id = gifttable.to
SQL LEFT JOIN 关键字