I am getting an error while running an update query with table name specified along with column name:
UPDATE Temp SET Temp.Id='234',Temp.Name='Test'WHERE Id='245'
This is the error:
ERROR: column "temp" of relation "temp" does not exist
LINE 1: UPDATE Temp SET Temp.Id='23...
^
********** Error **********
ERROR: column "temp" of relation "temp" does not exist
SQL state: 42703
Character: 24
Best Answer
You cannot (and need not) use table aliases (or tablename qualified column names) in the
SET
clause of anUPDATE
. This even makes sense, as you can only update a single table in a singleUPDATE
, so there is no ambiguity in column names there.Fortunately, the ever helpful documentation explicitly mentions your case:
So, the solution is to simply remove
temp.
from theSET
clause:Notes:
'mkjcvnd7y78r3tgbhvcjh'
entering yourid
column?temp
as opposed toTemp
. Using it the latter way may decrease readability (depending on your preferences and habits, of course).