Oracle中的外部加入帮助 [英] Outer join help in oracle

查看:50
本文介绍了Oracle中的外部加入帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有:

select title, order#, STATE
from customers C, ORDERITEMS O, books b
where b.ISBN=O.ISBN (+)
order by title

但是我试图理解为什么没有order#的行具有状态

But I'm trying to understand why rows that don't have order# have state

BODYBUILD IN 10 MINUTES A DAY   1003    CA
BODYBUILD IN 10 MINUTES A DAY   1003    WY
BODYBUILD IN 10 MINUTES A DAY   1003    TX
BODYBUILD IN 10 MINUTES A DAY   1003    NY
BODYBUILD IN 10 MINUTES A DAY   1003    WA
BODYBUILD IN 10 MINUTES A DAY   1003    ID
BODYBUILD IN 10 MINUTES A DAY   1003    FL
BUILDING A CAR WITH TOOTHPICKS  -   FL
BUILDING A CAR WITH TOOTHPICKS  -   NJ
BUILDING A CAR WITH TOOTHPICKS  -   GA
BUILDING A CAR WITH TOOTHPICKS  -   MI

推荐答案

您正在使用3个表,但只有一个联接.那会给你太多的结果.您将需要两个联接:可能以某种方式将表客户也需要与OrderItems联接.

You are using 3 tables, but only one join. That will get you too many results. You will need two joins: probably somehow table Customers needs to be joined with OrderItems too.

类似的东西:

and o.customerId = c.id

因此:

select b.title, o.order#, c.state
from customers c, orderitems o, books b
where o.customerId = c.id
and b.isbn = o.isbn (+)
order by title

这篇关于Oracle中的外部加入帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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