| От | Tom Lane |
|---|---|
| Тема | Re: [GENERAL] why isn't this subquery wrong? |
| Дата | |
| Msg-id | 30079.1492728230@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | [GENERAL] why isn't this subquery wrong? (jonathan vanasco <postgres@2xlp.com>) |
| Ответы |
Re: [GENERAL] why isn't this subquery wrong?
|
| Список | pgsql-general |
jonathan vanasco <postgres@2xlp.com> writes:
> Can anyone explain to me why the following is valid (running 9.6) ?
> SELECT foo_id
> FROM example_a__data
> WHERE foo_id IN (SELECT bar_id FROM example_a__rollup)
> ;
Per the SQL standard, bar_id is interpreted as an "outer reference"
to example_a__data.bar_id. This trips people up all the time, but
(a) it's required by spec and (b) there are cases where it's really
hard to do what you want without an outer reference.
Cautious SQL programmers qualify all references inside sub-selects
to avoid getting caught by this accidentally.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера