Non-procedural field merging?

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Non-procedural field merging?
Дата
Msg-id 000f01c076fe$2e27b9a0$1001a8c0@archonet.com
обсуждение исходный текст
Ответы Re: Non-procedural field merging?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
I have two tables, foo and foo2:

richardh=> select * from foo;a |  b
---+-----1 | xxx1 | yyy

richardh=> select * from foo2;c | d
---+---1 |

And I would like to set d to 'xxxyyy' (i.e. merge entries from b). Of course
the following doesn't work because the 'd' seen is the one from before the
query starts.

richardh=> update foo2 set d = d || foo.b from foo where foo.a=foo2.c;
UPDATE 1
richardh=> select * from foo2;c |  d
---+-----1 | yyy

Now - I can always solve the problem procedurally, merging the values in my
application but I was wondering if any of the smarter people on the list
have an SQL way of doing it (something with sub-queries?)

PS - I realise I might get 'xxxyyy' or 'yyyxxx' without forcing an order but
I don't actually care in this case.

TIA

- Richard Huxton



В списке pgsql-sql по дате отправления:

Предыдущее
От: Marc Cromme
Дата:
Сообщение: Extracting user db tabel info from system tables???
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Non-procedural field merging?