Re: [GENERAL] Secret Santa List

2015-12-23 Thread Lou Duchez
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

Re: [GENERAL] Secret Santa List

2015-12-23 Thread Kevin Grittner
On Tue, Dec 22, 2015 at 9:49 PM, Lou Duchez wrote: > 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

Re: [GENERAL] Secret Santa List

2015-12-23 Thread Thomas Kellerer
Lou Duchez schrieb am 23.12.2015 um 04:49: 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 stat

Re: [GENERAL] Secret Santa List

2015-12-23 Thread Alberto Cabello Sánchez
On Wed, Dec 23, 2015 at 04:32:34AM -0500, Lou Duchez wrote: > >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 re

Re: [GENERAL] Secret Santa List

2015-12-23 Thread Lou Duchez
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

Re: [GENERAL] Secret Santa List

2015-12-23 Thread Alberto Cabello Sánchez
On 23 December 2015 at 16:49, Lou Duchez wrote: > 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 wi

Re: [GENERAL] Secret Santa List

2015-12-22 Thread David Rowley
On 23 December 2015 at 16:49, Lou Duchez wrote: > 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 wi

[GENERAL] Secret Santa List

2015-12-22 Thread Lou Duchez
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: