Oracle SQL在两个子查询上留下了外部联接

时间:2018-07-13 15:45:10

标签: sql oracle join left-join

我在oracle数据库中工作,并收到以下错误:

用于SQL Server的Microsoft OLE DB提供程序:无效的对象名称

我也尝试加入where子句,但我也收到

以下是查询:

select UE_invoice.InvoiceNo,
       UE_invoice.DueDate,
       UE_payment.CheckNo,
       UE_payment.Amount

from

(select tblTransaction.InvoiceNo,
       tblTransaction.DueDate
  from tblTransaction,
       tblTransactionType
 where
 tblTransaction.Type = tblTransactionType.TransactionType
 and
 tblTransaction.Date >= '01/01/2018'
 and
 tblTransaction.Type = -88) UE_invoice,

(select tblTransaction.InvoiceNo,
       tblTransaction.DueDate,
       tblTransaction.CheckNo,
       tblTransaction.Amount
from tblTransaction,
     tblTransactionType
 where
 tblTransaction.Type = tblTransactionType.TransactionType
 and
 tblTransaction.Date >= '01/01/2018'
 and
 tblTransaction.Type = -86) UE_payment

Left outer join UE_invoice on UE_invoice.InvoiceNo = UE_payment.InvoiceNo

2 个答案:

答案 0 :(得分:1)

这不是使用“表表达式”的LEFT OUTER JOIN的语法。试试:

select UE_invoice.InvoiceNo,
       UE_invoice.DueDate,
       UE_payment.CheckNo,
       UE_payment.Amount
from (
  select tblTransaction.InvoiceNo,
       tblTransaction.DueDate,
       tblTransaction.CheckNo,
       tblTransaction.Amount
  from tblTransaction,
       tblTransactionType
  where
       tblTransaction.Type = tblTransactionType.TransactionType
    and
      tblTransaction.Date >= '01/01/2018'
    and
    tblTransaction.Type = -86
  ) UE_payment
Left outer join (
  select tblTransaction.InvoiceNo,
       tblTransaction.DueDate
  from tblTransaction,
       tblTransactionType
  where
       tblTransaction.Type = tblTransactionType.TransactionType
    and
       tblTransaction.Date >= '01/01/2018'
    and
    tblTransaction.Type = -88
  ) UE_invoice on UE_invoice.InvoiceNo = UE_payment.InvoiceNo

答案 1 :(得分:0)

尝试更换

Left outer join UE_invoice on UE_invoice.InvoiceNo = UE_payment.InvoiceNo

使用

where UE_invoice.InvoiceNo = UE_payment.InvoiceNo