Re: Inserting Multiple Random Rows

From: Justin Graf <justin(at)magwerks(dot)com>
To: pgsql-sql(at)postgresql(dot)org, Gary Chambers <gwchamb(at)gmail(dot)com>
Subject: Re: Inserting Multiple Random Rows
Date: 2010-04-28 19:03:34
Message-ID: 4BD88686.7070005@magwerks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 4/28/2010 1:48 PM, Gary Chambers wrote:
> pen?
>
> The clouds parting, choirs of angels singing, and fireworks
> celebrating the veil of my obtuseness being lifted, and my grasp and
> command of SQL to be complete and infinite. None of which appears
> will ever happen...
>
> -- Gary Chambers
>
> /* Nothing fancy and nothing Microsoft! */
>
>
You now what *_might _*work

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 IN (select round(random()*10000)::int as num from
generate_series(1,100000)) rand )

As you don't care if a record repeats

All legitimate Magwerks Corporation quotations are sent in a .PDF file attachment with a unique ID number generated by our proprietary quotation system. Quotations received via any other form of communication will not be honored.

CONFIDENTIALITY NOTICE: This e-mail, including attachments, may contain legally privileged, confidential or other information proprietary to Magwerks Corporation and is intended solely for the use of the individual to whom it addresses. If the reader of this e-mail is not the intended recipient or authorized agent, the reader is hereby notified that any unauthorized viewing, dissemination, distribution or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and destroy all occurrences of this e-mail immediately.
Thank you.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gary Chambers 2010-04-28 19:19:40 Re: Inserting Multiple Random Rows
Previous Message Gary Chambers 2010-04-28 17:48:36 Re: Inserting Multiple Random Rows