-
Notifications
You must be signed in to change notification settings - Fork 921
Closed
Labels
Description
If you define a new column in a subquery and do a join the new column can't be referenced by the containing query. A "does not exist" error is returned.
An example:
CREATE TABLE users (
user_id INT PRIMARY KEY
);
CREATE TABLE names (
user_id INT REFERENCES users,
first_name TEXT,
last_name TEXT
);
SELECT
user_id,
full_name
FROM users
JOIN (
SELECT
user_id,
first_name || last_name AS full_name
FROM names
) AS full_names USING (user_id);
Returns column "full_name" does not exist
, though the query is valid.
jakepeyser