如何在SQL中使用多个LEFT JOIN? [英] How to use multiple LEFT JOINs in SQL?

查看:4014
本文介绍了如何在SQL中使用多个LEFT JOIN?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在SQL查询中是否可以使用多个左联接?

Is it possible to use multiple left joins in sql query?

    LEFT JOIN
        ab 
    ON
        ab.sht = cd.sht

我想添加附加一个这样的查询吗? 能行吗?

i want to add to attach one more query like this to it? will it work?

    LEFT JOIN
        ab AND aa
    ON
        ab.sht = cd.sht
           AND
        aa.sht = cc.sht

这项工作可以吗?

推荐答案

是可以的.每个连接表都需要一个ON.

Yes it is possible. You need one ON for each join table.

LEFT JOIN ab
  ON ab.sht = cd.sht
LEFT JOIN aa
  ON aa.sht = cd.sht

偶然地,我对复杂SQL的个人格式设置在 http:/中进行了描述/bentilly.blogspot.com/2011/02/sql-formatting-style.html .如果您要编写很多这样的内容,可能会有所帮助.

Incidentally my personal formatting preference for complex SQL is described in http://bentilly.blogspot.com/2011/02/sql-formatting-style.html. If you're going to be writing a lot of this, it likely will help.

这篇关于如何在SQL中使用多个LEFT JOIN?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆