Re: searching multiple tables and databases

Поиск
Список
Период
Сортировка
От Richard Teviotdale
Тема Re: searching multiple tables and databases
Дата
Msg-id 006201c1688d$65855980$0100007f@satcomresources.com
обсуждение исходный текст
Ответ на searching multiple tables and databases  ("mike sears" <matrix@quadrent.net>)
Список pgsql-general
 
>I'm currently looking for the best way to search across multiple tables and databases.
 
You use a union query to join the results from multiple queries from different tables. For example:
 
Employees Table
1    Peter
2    Paul
3    Mary
 
Customers Table
1    John
2    Ringo
3    Paul
 
SELECT 'Employee' AS what, id, name
FROM Employees
WHERE name ~* '^P'
UNION
SELECT 'Customer' AS what, id, name
FROM Customers
WHERE name ~* '^P'
ORDER BY name;
 
Would return something like:
Employee    2    Paul
Customer    3    Paul
Employee    1    Peter
 
I can't tell you how you would do something like this accross multiple databases. There may be better ways...
 

В списке pgsql-general по дате отправления:

Предыдущее
От: Einar Karttunen
Дата:
Сообщение: Re: problem connecting client to a postgresSQL server
Следующее
От: mirko@picard.inka.de (Mirko Zeibig)
Дата:
Сообщение: Re: Why is there no option -U with pg_dump?