0

I am trying to update a table I created on a simple join. I have tried this many different ways and am still getting errors. Any help is appericated

Update well.formation_assignments as v
set
Primary_Formation = well.geo.primary_formation
from well.geo as s
inner join 
 on well.formation_assignments.api14=well.geo.api14;

ERROR: syntax error at or near "on" LINE 6: on well.formation_assignments.api14=well.geo.api14; ^ SQL state: 42601 Character: 123

1 Answer 1

1

Try this instead :

UPDATE well.formation_assignments v
SET Primary_Formation = s.primary_formation
FROM well.geo s
WHERE v.api14 = s.api14;

As standard Postgresql update syntax is as follows :

[ WITH [ RECURSIVE ] with_query [, ...] ]
UPDATE [ ONLY ] table [ [ AS ] alias ]
    SET { column = { expression | DEFAULT } |
          ( column [, ...] ) = ( { expression | DEFAULT } [, ...] ) } [, ...]
    [ FROM from_list ]
    [ WHERE condition | WHERE CURRENT OF cursor_name ]
    [ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]

Documentation : https://www.postgresql.org/docs/9.1/sql-update.html

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you I will try it. I appreciate your time

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.