I have a table with more than 30.000 entries and have to add a new column (zip_prefixes
) containing the first digit of the a zip code (zcta
).
I created the column successfully:
alter table zeta add column zip_prefixes text;
Then I tried to put the values in the column with:
update zeta
set zip_prefixes = (
select substr(cast (zctea as text)1,1)
from zeta)
)
Of course I got:
error more than one row returned by a subquery used as an expression
How can I get the first digit of the value from zctea
into column zip_prefixes
of the same row?