SQL Server 多个 LEFT JOIN,一对多
我正在寻找一种方法来执行从一个源表到多个表的多个联接。类似于以下内容:
SELECT a.NAME, b.address, c.phone
FROM tblname a
LEFT JOIN tbladdress b ON a.nid = b.nid
我还想同时在电话表 tblPhone
上执行左连接:
tblname a left join tblPhone c on a.PID = c.PID
尽我所能尝试,但我不知道如何将其放入一个查询中。
I am looking for a way to perform multiple joins from one source table to more than one table. Similar to the following:
SELECT a.NAME, b.address, c.phone
FROM tblname a
LEFT JOIN tbladdress b ON a.nid = b.nid
I also want to perform a left join on the Telephone table tblPhone
at the same time:
tblname a left join tblPhone c on a.PID = c.PID
Try as I might I can't see how to put this into one query.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以根据需要多次重复
JOIN
子句,例如:You can simply repeat your
JOIN
clauses as many times as is needed, e.g.: