0

I have a broken column with null values, however I have managed to import the data off a csv into TempTable

MediaRecords - localpath column is null

TempTable - localpath column is correct

UPDATE mediarecords SET localpath = TempTable.localpath FROM TempTable WHERE recordid = TempTable.recordid;

I keep getting ERROR: relation "temptable" does not exist LINE 3: FROM TempTable however I can browse the table and see the data.
I tried following this How to update selected rows with values from a CSV file in Postgres? and here we are

Bucky101
  • 1
  • 1
  • 1
    Can you do a select * from temptable . Also, post some sample create table syntax for both tables or screenshots – VTi Apr 26 '21 at 08:47

2 Answers2

0

Hu Bucky, can you check how the table is actually called because I see you referring at it as TempTable with camelcase and the error states temptable all lowercase.

PostgreSQL could be case sensitive. As example if you do the following

create table "TempTableABC" (id int);

Trying to select from temptableABC will fail

defaultdb=> select * from temptableABC;
ERROR:  relation "temptableabc" does not exist
LINE 1: select * from temptableABC;
                      ^

You'll need to use the same quoted syntax to make it work

defaultdb=> select * from "TempTableABC";
 id 
----
(0 rows)
Ftisiot
  • 1,808
  • 1
  • 7
  • 13
  • Hey, so SELECT * FROM public."TempTable"; works however UPDATE mediarecords SET localpath = TempTable.localpath FROM public."TempTable" WHERE recordid = TempTable.recordid; does not – Bucky101 Apr 26 '21 at 09:41
  • OK Cool, you set me on the correct path UPDATE mediarecords SET localpath = "TempTable".localpath FROM public."TempTable" WHERE "mediarecords".recordid = "TempTable".recordid; Works – Bucky101 Apr 26 '21 at 09:48
0

UPDATE mediarecords SET localpath = "TempTable".localpath
FROM public."TempTable"
WHERE "mediarecords".recordid = "TempTable".recordid;

Worked

Bucky101
  • 1
  • 1