Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 643BF632F34 for ; Wed, 28 Apr 2010 13:22:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 26403-04 for ; Wed, 28 Apr 2010 16:22:24 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pv0-f174.google.com (mail-pv0-f174.google.com [74.125.83.174]) by mail.postgresql.org (Postfix) with ESMTP id 7C64C632CE1 for ; Wed, 28 Apr 2010 13:22:24 -0300 (ADT) Received: by pvg2 with SMTP id 2so265853pvg.19 for ; Wed, 28 Apr 2010 09:22:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=am/+q5BrDxAfow3rqGON1Ggg/e90H2GZoqzWFs2xxlA=; b=nSBYkfdEzVo0pDSkZCs2Rf7VTvpd+i4akvBEXQwFZQ/hH98l75Ur71cDdeDAecphVN Rgf6wQw8mXccLr1p3s1xpWA4U4SX68RhElwM6+x3UGuJ0m37Xdmj3B8H5J0LNRaU57VQ F5DfrnNAUmDRlN/7Vqi/I12tgdPAJQjTobUTA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=IxYqSfm7V/7Qgqz180z0twTsREiGUAr6UUDoQYXImlDCUMb7m9hwxiVFXHSx3i+iOt BWAqv0HIHWkl1mV7FyVbqY5RsgH7unrk+ajTyuHHqEKDGlYmSlhbZxhhD0NH+OXy9CXR YRCj+7Z9XnqsdWlxs+M8TfUIReEqpoMvGr+f0= MIME-Version: 1.0 Received: by 10.142.61.35 with SMTP id j35mr4264100wfa.124.1272471743394; Wed, 28 Apr 2010 09:22:23 -0700 (PDT) Received: by 10.229.246.139 with HTTP; Wed, 28 Apr 2010 09:22:23 -0700 (PDT) Date: Wed, 28 Apr 2010 12:22:23 -0400 Message-ID: Subject: Inserting Multiple Random Rows From: Gary Chambers To: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.01 tagged_above=-10 required=5 tests=BAYES_40=-0.001, FREEMAIL_FROM=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201004/101 X-Sequence-Number: 34028 All, I have a table of user addresses that I'm trying to randomly populate with data from a cities table. Using the following query: 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? Thank you in advance. -- Gary Chambers /* Nothing fancy and nothing Microsoft! */