Using random() in update produces same random value for all

Поиск
Список
Период
Сортировка
От Alex Magnum
Тема Using random() in update produces same random value for all
Дата
Msg-id CA+cR4zde6SSaMfznJRgrM1zB2NYHjh6Uzn1ARXYW9_4sRvvUPA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Using random() in update produces same random value for all
Список pgsql-general
Hi,
i am trying to update a table with some random dates but that does not seem to work.

UPDATE table
   SET last_update=now()::date-(SELECT (random() * 5)::INTEGER + 1)

The updated field is always set to the same. Is there a way to make it random for every record?

I could run it through a function but I wonder if there is s simpler way.

Thanks for any help on this

Alex

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: psql format result as markdown tables
Следующее
От: Ken Tanzer
Дата:
Сообщение: Re: Using random() in update produces same random value for all