Re: Inserting Multiple Random Rows

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Inserting Multiple Random Rows
Дата
Msg-id 20335.1272474358@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Inserting Multiple Random Rows  (Gary Chambers <gwchamb@gmail.com>)
Ответы Re: Inserting Multiple Random Rows  (Gary Chambers <gwchamb@gmail.com>)
Список pgsql-sql
Gary Chambers <gwchamb@gmail.com> writes:
> INSERT INTO useraddrs(userid, addrdesc, city, stprov)
> SELECT u.userid, 'Home', c.cityname, c.stateabbr
> FROM users u, cities c
> WHERE u.userid NOT IN (SELECT userid FROM useraddrs)
>     AND cid=(SELECT cid FROM cities ORDER BY RANDOM() LIMIT 1);

> I am able to achieve most of what I am trying to accomplish, but once
> the random number is selected, it doesn't change.  What am I missing?

I believe the sub-SELECT will only get executed once, since it has no
dependency on the outer query.  What were you expecting to happen?
        regards, tom lane


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

Предыдущее
От: Gary Chambers
Дата:
Сообщение: Inserting Multiple Random Rows
Следующее
От: Justin Graf
Дата:
Сообщение: Re: Inserting Multiple Random Rows