Bjorn ten Broeke
Bjorn ten Broeke

Reputation: 145

Postgres - split number and letter doesnt fill column

I have received help for splitting a column wit nr and letter. In the SQL script it all works perfect. It runs complete, with no errors.

But the columns itself doesn't get filled. I have tried to create te columns in advance as text or as integer. But it doesn't get filled. The SQL query it self turn out ok. But in reality it stay empty. What is wrong?

Upvotes: 1

Views: 246

Answers (1)

harmic
harmic

Reputation: 30587

Your question is not completely clear, but it sounds like what you are trying to do is take a value from one column of a table, split it and use the result to update two other columns in the same table.

If that is the case, you would want to be using the SQL UPDATE command instead of SELECT.

UPDATE d1_plz_whatever
    SET nr=SUBSTRING(hn FROM '^[0-9]+'),
        zusatz =SUBSTRING(hn FROM '[a-zA-Z]+$');

Upvotes: 1

Related Questions