I am trying to create a new column in my parks database then calculate the area of the park but i keep getting this syntax error.

Can anyone see what is wrong with it?

alter table parks add column area double precision update parks set area = select st_area(geom) * power(0.3048,2) from parks;

There's more than one problem here:

  1. You should split it into 2 queries
  2. There shouldn't be a SELECT in your UPDATE
  3. Use a fixed number for the multiply, you might run the risk that your power is calculated over and over

Here's the query that should work:

ALTER TABLE parks ADD COLUMN area double precision;

UPDATE parks SET area = st_area(geom) * 0.09290304;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.