sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

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

Open ankisme opened this issue 2 years ago • 2 comments

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

ankisme avatar Jul 04 '23 09:07 ankisme

Hi everyone This error persist since 2022. Can someone ping the pull request https://github.com/sqlc-dev/sqlc/pull/3220 How one can possibly work without CTE or joins? Is SQLC only for primitive cases?

Please, pay attention to issues: https://github.com/sqlc-dev/sqlc/issues/2400 https://github.com/sqlc-dev/sqlc/issues/3169 https://github.com/sqlc-dev/sqlc/issues/1385

Though the solution of @smantic works well: https://github.com/sqlc-dev/sqlc/issues/1385#issuecomment-1571187337

Dmdv avatar May 15 '24 04:05 Dmdv