DROP TABLE IF EXISTS `lastidtest`; CREATE TABLE `lastidtest` ( `primary` int(10) unsigned NOT NULL auto_increment, `unique` int(10) NOT NULL default 0, `tochange` varchar(255) NOT NULL default '', PRIMARY KEY (`primary`), UNIQUE KEY `unique` (`unique`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO lastidtest SET `unique`=1, `tochange`='iwillchangethis' ON DUPLICATE KEY UPDATE `tochange`='itschanged'; status; SELECT LAST_INSERT_ID(); INSERT INTO lastidtest SET `unique`=2, `tochange`='justasecondrow' ON DUPLICATE KEY UPDATE `tochange`='itschanged'; STATUS; SELECT LAST_INSERT_ID(); SELECT * FROM lastidtest; INSERT INTO lastidtest SET `unique`=1, `tochange`='iwillchangethis' ON DUPLICATE KEY UPDATE `tochange`='itschanged'; STATUS; SELECT LAST_INSERT_ID(); SELECT * FROM lastidtest; INSERT INTO lastidtest SET `unique`=1, `tochange`='iwillchangethis' ON DUPLICATE KEY UPDATE `tochange`='itschanged'; STATUS; SELECT LAST_INSERT_ID();