I am returning to SQL after decades of not using it, so I have a bit of a noob question.
Here is my code:
CREATE TEMPORARY TABLE tempo
(LIKE tb_old INCLUDING ALL);
COPY tempo (id, notes, word)
FROM 'C:\www\export_lastline.csv'
WITH (FORMAT CSV, HEADER);
INSERT INTO tb_old (word, line_break)
SELECT word, 'TRUE'
FROM tempo
WHERE tempo.id = tb_old.id;
DROP TABLE tempo;
What exactly am I doing wrong here to throw this error?
ERROR: invalid reference to FROM-clause entry for table "tb_old" SQL
state: 42P01 Detail: There is an entry for table "tb_old", but it
cannot be referenced from this part of the query. Character: 239
I tried
`WHERE tempo['id'] = tb_old['id'];`
but it does not support sub-scripting either…
I have looked on-line for solutions yet only find examples of this error in relations to the JOIN command. I have a reference book on SQL and have looked at the online PostgreSQL manual, but don’t really know what I am doing wrong so it is kind of a blind search at this point.
I am trying to update a table in my database (db_old) using data from a CSV file that only contains a subset of IDs and add a bool value to indicate these entries are part of this subset of entries contained in the file C:\www\export_lastline.csv
.
You need to sign in to view this answers