Why not generate the required results in a SELECT then update from
that. row_number() could allow you to generate a random number to each
giver, then we can generate another random number and join to each
random number. That'll give you a giver and recipient combination.
e.g:
select giver,r
Of course: you can't UPDATE a field with a query returning more than one
result, as you can check easily trying:
I understand that, and my query does not return more than one result. The
problem is that it returns THE SAME result each time, most likely because the
subquery is evaluated exactl
I have a company with four employees who participate in a Secret Santa
program, where each buys a gift for an employee chosen at random. (For
now, I do not mind if an employee ends up buying a gift for himself.)
How can I make this work with an SQL statement?
Here is my Secret Santa table:
> >Certainly, I've
> >tried "grant select on database mydatabase to user myuser"; it doesn't
> >work, because "select" is not a database-level privilege.
> Sorry, you're right on that one. I misread it. However, it shouldn't
> be too hard to write a script, either in a procedural language or hi
> Lou Duchez wrote:
> >Like everyone else, I use pg_dump for backup purposes; I have a cron job
> >that runs a pg_dump whose output is then FTP'd elsewhere. Two things
> >that would make my life easier:
> >
> >1) "grant select on database ..." or, hy
Like everyone else, I use pg_dump for backup purposes; I have a cron job
that runs a pg_dump whose output is then FTP'd elsewhere. Two things
that would make my life easier:
1) "grant select on database ..." or, hypothetically, "grant select on
cluster". The goal would be to create a read-only Po