MySQL Forums
Forum List  »  Newbie

Re: Insert copy auto_increment to another column
Posted by: Umesh Shastry
Date: May 05, 2005 10:37PM

Hi!

I just tried this once again & its working fine for me...can you tell me which MySQL version you are using & also post your table structure..

from MyODBC Error Codes I noticed that this error(Error 23000) will be generated for Integrity constraint violation

This is the sample table I had created for testing..

# Generation Time: May 06, 2005 at 09:58 AM
# Server version: 4.0.18
# Database : `test`

#
# Table structure for table `mytable`
#

CREATE TABLE `mytable` (
`id` int(11) NOT NULL auto_increment,
`copy_id` int(11) NOT NULL default '0',
`fname` varchar(25) NOT NULL default '',
`lname` varchar(25) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=3 ;



INSERT INTO mytable VALUES
('','','umesh','shastry');
SELECT @last := LAST_INSERT_ID();
UPDATE mytable SET copy_id=@last where id=@last;

Regards,
Umesh Shastry
http://www.blogger.com/profile/02551756983528645221

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.