• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

这样的sql语句怎么写

php 搞代码 4年前 (2022-01-23) 19次浏览 已收录 0个评论
文章目录[隐藏]

一个礼物表: 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 关键字


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:这样的sql语句怎么写

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址