Your auto-increment could be effectively a row number. Otherwise there is this 
technique with user variables:

SET @rownum := 0;
SELECT @rownum:=...@rownum+1 as ROWNUM, ... FROM ... ;

Regards,
Gavin Towey


-----Original Message-----
From: Tom Goring [mailto:tom.gor...@gmail.com]
Sent: Friday, February 05, 2010 9:37 AM
To: mysql@lists.mysql.com
Subject: Business Key Generation

Hi,

I have a table that I need to migrate some data into:

CREATE TABLE `employee` (
  `employeeid` bigint(20) NOT NULL auto_increment,
..
  `reference` varchar(20) default NULL,
  `fkcompanyid` bigint(20) default NULL,
  PRIMARY KEY  (`employeeid`),
 KEY `FK4722E6AE82D7E095` (`fkcompanyid`),
CONSTRAINT `FK4722E6AE82D7E095` FOREIGN KEY (`fkcompanyid`) REFERENCES
`company` (`companyid`),
...
) ENGINE=InnoDB AUTO_INCREMENT=1000000000001585 DEFAULT CHARSET=latin1 |


My question is I want to generate a reference business key (a number) as the
migrated data is blank.

something like

update employee set reference = ROWNUM where fkcompanyid = X

I think in Oracle ROWNUM would help me do this.
I.e. generate a reference based on the position in the result set.

any Ideas ?

--
Tom Goring

This message contains confidential information and is intended only for the 
individual named.  If you are not the named addressee, you are notified that 
reviewing, disseminating, disclosing, copying or distributing this e-mail is 
strictly prohibited.  Please notify the sender immediately by e-mail if you 
have received this e-mail by mistake and delete this e-mail from your system. 
E-mail transmission cannot be guaranteed to be secure or error-free as 
information could be intercepted, corrupted, lost, destroyed, arrive late or 
incomplete, or contain viruses. The sender therefore does not accept liability 
for any loss or damage caused by viruses or errors or omissions in the contents 
of this message, which arise as a result of e-mail transmission. [FriendFinder 
Networks, Inc., 220 Humbolt court, Sunnyvale, CA 94089, USA, FriendFinder.com

Reply via email to