Skip to content

Sqlc could not support table alias (error: table alias "t1" does not exist) #2400

Open

Description

@ankisme

Version

1.18.0

What happened?

Sqlc could not support table alias, the sql example is in below.

The error message is "table alias "t1" does not exist"

Relevant log output

No response

Database schema

CREATE TABLE authors (
          id   BIGINT PRIMARY KEY AUTO_INCREMENT,
          name text      NOT NULL,
          bio  text
);

SQL queries

/* name: ListAuthors2 :many */
select * from (SELECT * FROM authors) as t1 where t1.id > ?;

Configuration

No response

Playground URL

No response

What operating system are you using?

No response

What database engines are you using?

No response

What type of code are you generating?

No response

Activity

  1. added
    bugSomething isn't working
    triageNew issues that hasn't been reviewed
    on Jul 4, 2023
  2. added this to the 1.27.0 milestone on Apr 4, 2024
  3. Dmdv commented on May 15, 2024

    @Dmdv

    Hi everyone
    This error persist since 2022.
    Can someone ping the pull request #3220
    How one can possibly work without CTE or joins?
    Is SQLC only for primitive cases?

    Please, pay attention to issues:
    #2400
    #3169
    #1385

    Though the solution of @smantic works well:
    #1385 (comment)

  4. removed this from the 1.27.0 milestone on Aug 5, 2024
  5. dev-kpyc commented on Nov 17, 2025

    @dev-kpyc

    @kyleconroy any plans to fix this issue?

    I see this previous PR to address this was ultimately reverted: #3299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions