test=*# create table flurstueck(id int primary key, name text);
CREATE TABLE
test=*# insert into flurstueck (id) values (1);
INSERT 0 1
test=*# insert into flurstueck (id) values (4);
INSERT 0 1
test=*# insert into flurstueck (id) values (16);
INSERT 0 1
test=*# insert into flurstueck (id) values (18);
INSERT 0 1
test=*# select * from flurstueck ;
id | name
----+------
1 |
4 |
16 |
18 |
(4 rows)
test=*# with owner as (select name, regexp_split_to_table(grundstuecke,',') from zuordnung ) update flurstueck set name = owner.name from owner where id=regexp_split_to_table::int;
UPDATE 4
test=*# select * from flurstueck ;
id | name
----+---------
1 | Klaus
4 | Klaus
16 | Karolin
18 | Karolin
(4 rows)
test=*#
Für die Zukunft beschäftige Dich bitte mit Tabellendesign.