0

我正在使用带有 Visual Foxpro 后端的会计系统。每个月,所有发票和付款都会从当前发票/付款表移动到一个新表(在不同的目录中),其中仅包含该月的数据。例如:

MainDBDir
    currentInvoices.dbf   (contains Dec invoices)
    currentPayments.dbf  (contains Dec payments)
    2010Dir
        NovDir
            invoices.dbf (contains Nov2010 invoices)
            payments.dbf (contains Nov2010 payments)
        OctDir
            invoices.dbf (contains Oct2010 invoices)
            payments.dbf (contains Oct2010 payments)

我需要对过去六个月的数据执行查询。有没有一种方法可以在单个 Visual Foxpro 查询中连接多个表(来自多个目录)?

我需要这样的东西:

 select * from concatenate(currentInvoices, 2010Dir/NovDir/invoices.dbf, 2010Dir/OctDir/invoices) where invoice_number like '12345'

我宁愿不为每个表执行单独的查询......

谢谢-

乔纳森

4

1 回答 1

3

You can concatenate the queries by using a union statement.

Example:

select * from currentInfoices.dbf
  where invoice_number like '12345'
union
select * from "2010Dir\OctDir\invoices.dbf"
  where invoice_number like '12345'
union
select * from "2010Dir\NovDir\invoices.dbf"
    where invoice_number like '12345'

or

select * 
  from (select * from currentInfoices.dbf
          union select * from "2010Dir\OctDir\invoices.dbf"
     union select * from "2010Dir\NovDir\invoices.dbf") q
  where invoice_number like '12345'
于 2010-12-13T19:57:28.110 回答