My code constructs some queries by passing in constraint clauses like type = 'A' However one of the constraint clauses is exists (select 1 from othertable where x = outertable.x) This works fine, but requires that the caller know that the table being queried will be "outertable". Is there any way in a subquery used like this to implicitly reference fields from the outer query? -- greg
Greg Stark <gsstark@mit.edu> writes:
> However one of the constraint clauses is
> exists (select 1 from othertable where x = outertable.x)
> This works fine, but requires that the caller know that the table being
> queried will be "outertable". Is there any way in a subquery used like this to
> implicitly reference fields from the outer query?
If the column name does not belong to any of the tables of the inner
query then it will automatically be sought in the outer query. If you
are dealing with a name that does appear at both levels, you're outta
luck ... got to qualify it.
regards, tom lane
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера