List:General Discussion« Previous MessageNext Message »
From:(Hal Date:July 5 2012 3:26pm
Subject:group_key?
View as plain text  
Here is something queer:

select ifnull(email, round(10000 * rand(), 1)) as ux, count(*) from nam group by ux;
ERROR 1062 (23000): Duplicate entry '2514.0' for key 'group_key'

I have a name-list, with e-mail address or not. I wanted to fill the NULL e-mail addresses
with something random, and, I hope, unique. (ROUND is there only to make that surprising
error liklier.)

The field "email" is not UNIQUE, not a key, no intention of making it such.

Why this error? Is RAND called more than once for each record?

I tryed also UUID, but that came with its own shortcoming: if the UUID call were the whole
field, it indeed was once called for every record, but if argument to IFNULL, only once
for the whole query.

Version 5.5.8

Thread
group_key?hsv5 Jul
  • Re: group_key?Claudio Nanni5 Jul
    • Re: group_key?hsv6 Jul