Re: [GENERAL] Negating the list of selected rows of a join
В списке pgsql-general по дате отправления:
| От | Clark Evans |
|---|---|
| Тема | Re: [GENERAL] Negating the list of selected rows of a join |
| Дата | |
| Msg-id | 36EB7179.206BD7CB@manhattanproject.com обсуждение исходный текст |
| Ответ на | Negating the list of selected rows of a join ("Manuel Lemos" <mlemos@acm.org>) |
| Список | pgsql-general |
Manuel Lemos wrote: > > I want to list the rows of a table with a text field whose values do not > exist in a similar field of another table. Basically what I want to get > is negated results of a join. Ulf Mehlig wrote: > SELECT name FROM table_a > WHERE name NOT IN (SELECT name FROM table_b); Clark Evans wrote: > SELECT table_a.name, table_a.age > FROM table_a > WHERE NOT EXISTS ( > SELECT 'x' > FROM table_b > WHERE table_b.name = table_a.name > ); I'm not sure about how well PostgreSQL handles these two. I'd try them both with your data set. If table_b is small (less than a few thousand rows) then Ulf's approach would work best. However, if table_b is large (more than a thousand) then I think the other approach may work better if table_b.name is indexed. Clark
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера