Self-Alias not found (subquery using alias of its outer query)
See original GitHub issuehttps://oguimbal.github.io/pg-mem-playground/
CREATE TABLE my_table (id text NOT NULL PRIMARY KEY, name text NOT NULL, parent_id text);
CREATE INDEX my_table_idx_name ON my_table (name);
CREATE INDEX my_table_idx_id_parent_id ON my_table (id,parent_id);
SELECT * FROM my_table as t1 WHERE t1.name = 'test';
SELECT * FROM my_table as t1 WHERE t1.name = 'test' AND NOT EXISTS (SELECT * FROM my_table as t2 WHERE t2.parent_id = t1.id);
Alias 't1' not found
🐜 This seems to be an execution error, which means that your request syntax seems okay,
but the resulting statement cannot be executed → Probably not a pg-mem error.
*️⃣ Reconsituted failed SQL statement: SELECT * FROM "my_table" AS "t1" WHERE (("t1"."name" = ('test')) AND (NOT ("exists"((SELECT * FROM "my_table" AS "t2" WHERE ("t2"."parent_id" = "t1"."id") )))))
👉 You can file an issue at https://github.com/oguimbal/pg-mem along with a way to reproduce this error (if you can), and the stacktrace:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:7 (2 by maintainers)
Top Results From Across the Web
subquery in FROM must have an alias - Stack Overflow
I have a similar query in Oracle that works fine. The only change is where I have EXCEPT in Oracle I have replaced...
Read more >How to Fix The "Every derived table must have its own alias ...
The short answer is you need to give your subqueries an alias in your SELECT statement. Add an alias after the closing bracket...
Read more >How to Use Aliases in SQL Queries - LearnSQL.com
There are several ways to use aliases in your SQL queries. This article shows you how, using simple explanations and helpful examples.
Read more >Query syntax | BigQuery - Google Cloud
query_expr. ( query_expr ) [ [ AS ] alias ] is a table subquery. ... If no rule is available for any STRUCT...
Read more >U115: Subquery in FROM must have an alias - pganalyze
The correct fix is to give the subquery in the FROM clause an alias (i.e. a name), so that it can be uniquely...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Just popping in to +1 this. It’s impacting my NestJS project as well. As AustinGil said though, take your time. You are doing an amazing job with this library and I am very grateful for all your effort. ^_^
I should’ve searched existing tickets before submitting mine. Seems test coverage is already done in the new branch, so that’s promising. Thanks!