我正在使用带有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'
我不想为每个表执行单独的查询...
谢谢 -
Jonathan
答案 0 :(得分: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'