I have photos
table onto which I'm trying to insert a new column from another table by filtering data with a WHERE
clause. Here is the query I'm trying to execute:
ALTER TABLE photos ADD COLUMN new_count BIGINT;
INSERT INTO photos (new_count)
SELECT c.cnt
FROM c
WHERE
c.created = photos.created;
But in the result I am getting an error:
Error : ERROR: invalid reference to FROM-clause entry for table "photos"
LINE 5: c.created = photos.created
How can avoid the error and copy the column?
I'm using PostgreSQL 9.4.