Обсуждение: Dynamic update

Поиск
Список
Период
Сортировка

Dynamic update

От
Simon Drabble
Дата:
Is it possible to update a column with another column's value, say

UPDATE member SET votes = `SELECT count(votes) FROM ballot WHERE id = 1`;

with or without aggregates?

Tried everything I can think of, searched the docs, reading the finished parts
of Bruce's book...

If not, are there truly dynamic SQL-only (i.e. without resorting to external
functions) ways to achieve this? Am I being obtuse and missing something
obvious?


Simon.

--
 "Linux - open doors, not windows."

   Simon Drabble                      It's like karma for your brain.
   simon@eskimo.com


Re: [GENERAL] Dynamic update

От
"Aaron J. Seigo"
Дата:
hi...

> UPDATE member SET votes = `SELECT count(votes) FROM ballot WHERE id = 1`;

> If not, are there truly dynamic SQL-only (i.e. without resorting to external
> functions) ways to achieve this? Am I being obtuse and missing something
> obvious?

i don't know if pl/pgsql fits your definition of an "external function", but...
if not... a simple pl/pgsql function would do this handily...



--
Aaron J. Seigo
Sys Admin