Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column not found in correlated subquery, when referencing outer column from LEFT JOIN .. ON clause #3945

Open
lukaseder opened this issue Dec 11, 2023 · 4 comments

Comments

@lukaseder
Copy link
Contributor

I'm using H2 2.2.224

This query works:

with
  a(a) as (values (1)),
  b(b) as (values (1)),
  c(c) as (values (1))
select 
  a.a,
  (
    select b.b
    from b
    join c
    on b.b = a.a
    and c.c = b.b
  )
from a;

This one doesn't

with
  a(a) as (values (1)),
  b(b) as (values (1)),
  c(c) as (values (1))
select 
  a.a,
  (
    select b.b
    from b
    left join c -- Difference here
    on b.b = a.a
    and c.c = b.b
  )
from a;

The error is:

Column "A.A" not found; SQL statement:

I don't think there's a good reason for A.A being out of scope at that location?

@grandinj
Copy link
Contributor

In general, the entirety of the WITH functionality is dodgy and needs to be rewritten, but no-one currently feels up to that.

@lukaseder
Copy link
Contributor Author

OK, sure, but it's not related to WITH:

create table a (a int);
create table b (b int);
create table c (c int);

select 
  a.a,
  (
    select b.b
    from b
    left join c
    on b.b = a.a
    and c.c = b.b
  )
from a;

@manticore-projects
Copy link
Contributor

This is still relevant after @katzyn's latest work on WITH and CTE, I have just re-tested it against latest GIT 4497462

@manticore-projects
Copy link
Contributor

Could be a duplicate of #3716

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants