Re: Search for data in a similar field in a related table, too
В списке pgsql-novice по дате отправления:
| От | Bruno Wolff III |
|---|---|
| Тема | Re: Search for data in a similar field in a related table, too |
| Дата | |
| Msg-id | 20030910130551.GA25627@wolff.to обсуждение |
| Ответ на | Search for data in a similar field in a related table, too ("szucs" <janos.szucs@meei.hu>) |
| Список | pgsql-novice |
On Wed, Sep 10, 2003 at 11:26:27 +0200, szucs <janos.szucs@meei.hu> wrote: > I have 2 tables: > > MainTable, fields: id, data1 > RelatedTable, fields: id, data2 > > RelatedTable is joined to MainTable via the 'id' field. > Field 'data2' in RelatedTable holds the same sort of data as 'data1' in > MainTable, though they may be different in length. > > I could not figure out an SQL query, which returns all records where either > 'data1' in the MainTable or 'data2' in the joined RelatedTable complies with > a common search condition. > (For the case of simplicity I did not mention that MainTable has more > fields, for which separate seach conditions may apply) > > Is it possible to construct such an SQL query? Yes. Join the two tables and repeat the search condition for data1 and data2 using 'or' as a connector (and probably with surrounding parens).
В списке pgsql-novice по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера