Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在Oracle中组合此sql查询?_Sql_Oracle - Fatal编程技术网

如何在Oracle中组合此sql查询?

如何在Oracle中组合此sql查询?,sql,oracle,Sql,Oracle,我有一个sql查询,可以提取各种信息。部分原因如下 select gsm.mobile_no, emp.employee_id, d.department_id from data gsm, employees emp, department d where gsm.code = e.code and d.id = e.id 现在,在另一个名为“call”的表中有一个名为roaming的列。问题出在这里。呼叫表中只有一些移动电话号码的信息,因此当我加入gsm.code=call

我有一个sql查询,可以提取各种信息。部分原因如下

  select gsm.mobile_no, emp.employee_id, d.department_id
  from data gsm, employees emp, department d
  where gsm.code = e.code
  and d.id = e.id
现在,在另一个名为“call”的表中有一个名为roaming的列。问题出在这里。呼叫表中只有一些移动电话号码的信息,因此当我加入gsm.code=call.id时,如下所示

  select gsm.mobile_no, emp.employee_id, d.department_id, roaming.name 
  from data gsm, employees emp, department d, call roaming
  where gsm.code = e.code
  and d.id = e.i
  and roaming.id = gsm.code
然后我会丢失有关员工和部门的信息,因为只有满足roaming.id=gsm.code条件的记录才会被检索,所以我会丢失有关部门、员工和所有其他移动电话号码的信息。我想从所有表中检索所有记录,包括适用的移动电话号码的roaming.id,如果没有某些移动电话号码的可用数据,则显示null,但我希望显示所有记录。
我怎么能做到这一点呢?

现在是你进入现代
join
语法世界的时候了。将您的
join
条件放在
on
子句中,并记住一条简单规则:在
from
子句中不要使用逗号

您需要的是一个
左外连接
。在
where
子句中不能真正做到这一点。好吧,你可以在Oracle中使用,但它并不漂亮,也不如真正的
左外连接好

select gsm.mobile_no, emp.employee_id, d.department_id, roaming.name 
from employes left outer join
     data gsm
     on gsm.code = e.code left join
     department d
     on d.id = e.i left outer join
     call roaming
     on  roaming.id = gsm.code;

虽然可以混合使用内部联接和外部联接,但您希望保留所有员工。因此,从该表开始,让所有联接
左外部联接

进入现代
联接
语法世界的时候到了。将您的
join
条件放在
on
子句中,并记住一条简单规则:在
from
子句中不要使用逗号

select gsm.mobile_no, emp.employee_id, d.department_id, roaming.name 
from employes left outer join
     data gsm
     on gsm.code = e.code left join
     department d
     on d.id = e.i left outer join
     call roaming
     on  roaming.id = gsm.code;
您需要的是一个
左外连接
。在
where
子句中不能真正做到这一点。好吧,你可以在Oracle中使用,但它并不漂亮,也不如真正的
左外连接好

select gsm.mobile_no, emp.employee_id, d.department_id, roaming.name 
from employes left outer join
     data gsm
     on gsm.code = e.code left join
     department d
     on d.id = e.i left outer join
     call roaming
     on  roaming.id = gsm.code;

虽然可以混合使用内部联接和外部联接,但您希望保留所有员工。因此,从该表开始,让所有联接
左外部联接

进入现代
联接
语法世界的时候到了。将您的
join
条件放在
on
子句中,并记住一条简单规则:在
from
子句中不要使用逗号

select gsm.mobile_no, emp.employee_id, d.department_id, roaming.name 
from employes left outer join
     data gsm
     on gsm.code = e.code left join
     department d
     on d.id = e.i left outer join
     call roaming
     on  roaming.id = gsm.code;
您需要的是一个
左外连接
。在
where
子句中不能真正做到这一点。好吧,你可以在Oracle中使用,但它并不漂亮,也不如真正的
左外连接好

select gsm.mobile_no, emp.employee_id, d.department_id, roaming.name 
from employes left outer join
     data gsm
     on gsm.code = e.code left join
     department d
     on d.id = e.i left outer join
     call roaming
     on  roaming.id = gsm.code;

虽然可以混合使用内部联接和外部联接,但您希望保留所有员工。因此,从该表开始,让所有联接
左外部联接

进入现代
联接
语法世界的时候到了。将您的
join
条件放在
on
子句中,并记住一条简单规则:在
from
子句中不要使用逗号

select gsm.mobile_no, emp.employee_id, d.department_id, roaming.name 
from employes left outer join
     data gsm
     on gsm.code = e.code left join
     department d
     on d.id = e.i left outer join
     call roaming
     on  roaming.id = gsm.code;
您需要的是一个
左外连接
。在
where
子句中不能真正做到这一点。好吧,你可以在Oracle中使用,但它并不漂亮,也不如真正的
左外连接好

select gsm.mobile_no, emp.employee_id, d.department_id, roaming.name 
from employes left outer join
     data gsm
     on gsm.code = e.code left join
     department d
     on d.id = e.i left outer join
     call roaming
     on  roaming.id = gsm.code;

虽然可以混合使用内部联接和外部联接,但您希望保留所有员工。因此,从该表开始,使所有联接
左外部联接

如何更改查询以使用?在
内部联接的位置使用
左联接
,在
上的条件的位置使用
上的联接条件
何处
如何更改查询以使用?使用
左联接
内部连接的位置
中的连接条件在
中的位置
如何更改要使用的查询?在
内部连接的位置使用
左连接
中的连接条件在
中的位置
如何更改要使用的查询?在
内部联接
的位置使用
左联接
,在
的位置使用
中的联接条件,在
中的条件
哦,这将是大量的重写,因为我已经以WHERE子句的形式获得了大量的其他内部联接。有可能在where子句中只使用一次左外连接吗?哦,那将是一个很大的重写,因为我有大量其他where子句形式的内部连接。有可能在where子句中只使用一次左外连接吗?哦,那将是一个很大的重写,因为我有大量其他where子句形式的内部连接。有可能在where子句中只使用一次左外连接吗?哦,那将是一个很大的重写,因为我有大量其他where子句形式的内部连接。在where子句中可以只使用一次左外连接吗?
select gsm.mobile_no, emp.employee_id, d.department_id, roaming.name 
from employes left outer join
     data gsm
     on gsm.code = e.code left join
     department d
     on d.id = e.i left outer join
     call roaming
     on  roaming.id = gsm.code;