• <tfoot id='04sd4'></tfoot>
        <legend id='04sd4'><style id='04sd4'><dir id='04sd4'><q id='04sd4'></q></dir></style></legend>

        <small id='04sd4'></small><noframes id='04sd4'>

          <bdo id='04sd4'></bdo><ul id='04sd4'></ul>
      1. <i id='04sd4'><tr id='04sd4'><dt id='04sd4'><q id='04sd4'><span id='04sd4'><b id='04sd4'><form id='04sd4'><ins id='04sd4'></ins><ul id='04sd4'></ul><sub id='04sd4'></sub></form><legend id='04sd4'></legend><bdo id='04sd4'><pre id='04sd4'><center id='04sd4'></center></pre></bdo></b><th id='04sd4'></th></span></q></dt></tr></i><div id='04sd4'><tfoot id='04sd4'></tfoot><dl id='04sd4'><fieldset id='04sd4'></fieldset></dl></div>

      2. 什么时候使用左外连接?

        时间:2023-10-08

          <tbody id='4oPyc'></tbody>
        <i id='4oPyc'><tr id='4oPyc'><dt id='4oPyc'><q id='4oPyc'><span id='4oPyc'><b id='4oPyc'><form id='4oPyc'><ins id='4oPyc'></ins><ul id='4oPyc'></ul><sub id='4oPyc'></sub></form><legend id='4oPyc'></legend><bdo id='4oPyc'><pre id='4oPyc'><center id='4oPyc'></center></pre></bdo></b><th id='4oPyc'></th></span></q></dt></tr></i><div id='4oPyc'><tfoot id='4oPyc'></tfoot><dl id='4oPyc'><fieldset id='4oPyc'></fieldset></dl></div>
          • <small id='4oPyc'></small><noframes id='4oPyc'>

              <legend id='4oPyc'><style id='4oPyc'><dir id='4oPyc'><q id='4oPyc'></q></dir></style></legend>
                <bdo id='4oPyc'></bdo><ul id='4oPyc'></ul>
                • <tfoot id='4oPyc'></tfoot>
                  本文介绍了什么时候使用左外连接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我不明白左外连接、右外连接的概念,或者根本不明白为什么我们需要使用连接!我正在努力解决的问题以及我正在使用的表格在这里:链接

                  I don't understand the concept of a left outer join, a right outer join, or indeed why we need to use a join at all! The question I am struggling with and the table I am working from is here: Link

                  问题 3(b)

                  在 SQL 中构造一个命令来解决以下查询,解释为什么它必须使用(外)连接方法.[5 分]找出每位工作人员及其受抚养配偶的姓名(如果有)"

                  Construct a command in SQL to solve the following query, explaining why it had to employ the (outer) join method. [5 Marks] "Find the name of each staff member and his/her dependent spouse, if any"

                  问题 3(c) -

                  在 SQL 中构造一个命令来解决以下查询,使用 (i) 连接方法,以及 (ii)子查询方法.[10 分]找到每个工作超过 20 小时的工作人员的身份名称计算机化项目"

                  Construct a command in SQL to solve the following query, using (i) the join method, and (ii) the subquery method. [10 Marks] "Find the identity name of each staff member who has worked more than 20 hours on the Computerization Project"

                  谁能给我简单解释一下?

                  Can anyone please explain this to me simply?

                  推荐答案

                  Join 用于将两个相关的表组合在一起.

                  Joins are used to combine two related tables together.

                  在您的示例中,您可以组合 Employee 表和 Department 表,如下所示:

                  In your example, you can combine the Employee table and the Department table, like so:

                  SELECT FNAME, LNAME, DNAME
                  FROM
                  EMPLOYEE INNER JOIN DEPARTMENT ON EMPLOYEE.DNO=DEPARTMENT.DNUMBER
                  

                  这将导致像这样的记录集:

                  This would result in a recordset like:

                  FNAME   LNAME   DNAME
                  -----   -----   -----
                  John    Smith   Research
                  John    Doe     Administration
                  

                  我在上面使用了 INNER JOIN.INNER JOIN 合并两个表,以便 显示两个表中匹配的记录,并且在这种情况下,它们在部门中加入编号(Employee 中的字段 DNO,Department 表中的 DNUMBER).

                  I used an INNER JOIN above. INNER JOINs combine two tables so that only records with matches in both tables are displayed, and they are joined in this case, on the department number (field DNO in Employee, DNUMBER in Department table).

                  LEFT JOINs 允许您在第一个表中有记录但可能没有在第二个表中有记录时合并两个表.例如,假设您想要一个包含所有员工以及所有家属的列表:

                  LEFT JOINs allow you to combine two tables when you have records in the first table but might not have records in the second table. For example, let's say you want a list of all the employees, plus any dependents:

                  SELECT EMPLOYEE.FNAME as employee_first, EMPLOYEE.LNAME as employee_last, DEPENDENT.FNAME as dependent_last, DEPENDENT.LNAME as dependent_last
                  FROM
                  EMPLOYEE INNER JOIN DEPENDENT ON EMPLOYEE.SSN=DEPENDENT.ESSN
                  

                  这里的问题是,如果员工没有受抚养人,那么他们的记录根本不会显示——因为 DEPENDENT 表中没有匹配的记录.

                  The problem here is that if an employee doesn't have a dependent, then their record won't show up at all -- because there's no matching record in the DEPENDENT table.

                  因此,您使用 left 连接,它将所有数据保留在左"(即第一个表)上,并在右"(第二个表)上拉入任何匹配数据:

                  So, you use a left join which keeps all the data on the "left" (i.e. the first table) and pulls in any matching data on the "right" (the second table):

                  SELECT EMPLOYEE.FNAME as employee_first, EMPLOYEE.LNAME as employee_last, DEPENDENT.FNAME as dependent_first, DEPENDENT.LNAME as dependent_last
                  FROM
                  EMPLOYEE LEFT JOIN DEPENDENT ON EMPLOYEE.SSN=DEPENDENT.ESSN
                  

                  现在我们获得了所有的员工记录.如果给定员工没有匹配的受抚养人,dependent_firstdependent_last 字段将为空.

                  Now we get all of the employee records. If there is no matching dependent(s) for a given employee, the dependent_first and dependent_last fields will be null.

                  这篇关于什么时候使用左外连接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么SqlServer select语句会选择匹配的行和匹配并带有尾随空格的行 下一篇:MySQL如何连接两个字段上的表

                  相关文章

                • <legend id='hLNaW'><style id='hLNaW'><dir id='hLNaW'><q id='hLNaW'></q></dir></style></legend>
                  <tfoot id='hLNaW'></tfoot>

                  <small id='hLNaW'></small><noframes id='hLNaW'>

                    <i id='hLNaW'><tr id='hLNaW'><dt id='hLNaW'><q id='hLNaW'><span id='hLNaW'><b id='hLNaW'><form id='hLNaW'><ins id='hLNaW'></ins><ul id='hLNaW'></ul><sub id='hLNaW'></sub></form><legend id='hLNaW'></legend><bdo id='hLNaW'><pre id='hLNaW'><center id='hLNaW'></center></pre></bdo></b><th id='hLNaW'></th></span></q></dt></tr></i><div id='hLNaW'><tfoot id='hLNaW'></tfoot><dl id='hLNaW'><fieldset id='hLNaW'></fieldset></dl></div>

                        <bdo id='hLNaW'></bdo><ul id='hLNaW'></ul>