Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PSQL join - Column "table.column" does not exist

I need to update records in a table but only if a certain column of this table equals the content of a column of another table.

But first, just to be sure, I want to select all of the records that meets this specific so I've tried something like:

SELECT * FROM "table1" as ARR INNER JOIN "table2" as AOP ON ("AOP.col2" = "ARR.col1");

But the query returns this error:

ERROR: column "AOP.col2" does not exist
LINE 1: ...as ARR INNER JOIN "table2" as AOP ON ("AOP.col...

What am I doing wrong? (obviously the column does exist)
Seeing this error do you think the following update query will also fail?

UPDATE "table2" AS AOP
SET "col2" = "ARR.col1"
FROM "table1" AS ARR
WHERE "AOP.col3" = "ARR.col4";
like image 394
Leon Avatar asked May 30 '26 07:05

Leon


1 Answers

[SOLVED]

If anyone's interested in the solution this is it:

SELECT * FROM "table1" as "ARR" INNER JOIN "table2" as "AOP" ON ("AOP"."col2" = "ARR"."col1");
like image 109
Leon Avatar answered May 31 '26 22:05

Leon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!