2010-12-13 36 views
0

我正在使用Visual Foxpro後端的會計系統。每個月,所有的發票和付款都會從當前的發票/付款表中移到一個新的表格(在不同的目錄中),只有該月份的數據。例如:添加多個表格的內容 - 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' 

我寧可不爲每個表執行一個單獨的查詢......

Thanks-

喬納森

回答

3

,可以串聯通過使用union語句進行查詢。

實施例:

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' 

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'