Добавление содержимого нескольких таблиц - 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'

Я бы не стал выполнять отдельный запрос для каждой таблицы...

Спасибо-

Джонатан


person Jonathan    schedule 13.12.2010    source источник


Ответы (1)


Вы можете объединить запросы, используя оператор объединения.

Пример:

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'
person Tom Brothers    schedule 13.12.2010