Justin (et al),
> You now what might work
In the interest of efficiency, I abandoned the quest for the perfect
query and wrote my own function and used a modified version of
depesz's get_random_id() function:
CREATE OR REPLACE FUNCTION gen_fake_addresses() RETURNS INTEGER AS
$gen_fake_addresses$
Justin,
Thanks for the reply!
> you need to generate a series of random numbers then select each record
> one at a time out of cities table . You will have to write a plsql
> function to do this As any join will cause the result to be ordered.
After modifying my search terms at Google, I've dis
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 Chamber
Tom,
> I believe the sub-SELECT will only get executed once, since it has no
> dependency on the outer query.
That seems to be the behavior its exhibiting.
> What were you expecting to happen?
The clouds parting, choirs of angels singing, and fireworks
celebrating the veil of my obtuseness bein
That won't work because Order by does not recompute Random() once gets a
number it stops
you need to generate a series of random numbers then select each record
one at a time out of cities table . You will have to write a plsql
function to do this As any join will cause the result to be order
Gary Chambers 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
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