Postgres referencing column in an INSERT / select join?

15 views Asked by At

I have a somewhat complex set of queries, the relevant part is this:

INSERT INTO my_table (product_id, ... ) 
(SELECT replace(stuff...) as "product_id", ...
FROM sku_table SKU 
/* multiple joins */
LEFT JOIN table2 T2 ON SKU."product_id"=T2."product_id" 
...

On addition of the LEFT JOIN PG complains it can't find column product_id (regardless of quotes/no quotes) in the left table.

How can I refer in the join to the column selected from SKU table here?

0

There are 0 answers