Autoincrement ID copied by trigger
Hi,
I've got a simply trigger that copies fields from one table to another in a different DB on the same server. Both source and destination tables use the column id as an auto-increment as the primary key.
In the trigger I explicitly exclude the source id value but for some reason when it inserts into the target table it uses the same id value as the source rather than using it's own auto-increment value. How can I stop this? FYI this is an AFTER_INSERT trigger.
BEGIN
INSERT INTO mastergps.gps
(tstamp, deviceid, lat, lng, speed, alt)
VALUES
(NEW.tstamp,NEW.radioid, NEW.lat, NEW.lng, NEW.speed, NEW.alt);
END
This is the source table:
CREATE TABLE `gps` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tstamp` datetime DEFAULT NULL,
`radioid` int(11) DEFAULT '0',
`lat` double DEFAULT '0',
`lng` double DEFAULT '0',
`ngr` varchar(16) DEFAULT NULL,
`speed` double DEFAULT '0',
`alt` double DEFAULT '0',
PRIMARY KEY (`id`),
KEY `radioid` (`radioid`)
) ENGINE=InnoDB AUTO_INCREMENT=10647 DEFAULT CHARSET=latin1;
This is the target table:
CREATE TABLE `gps` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tstamp` datetime DEFAULT NULL,
`deviceid` double DEFAULT '0',
`lat` double DEFAULT '0',
`lng` double DEFAULT '0',
`speed` double DEFAULT '0',
`alt` double DEFAULT '0',
PRIMARY KEY (`id`),
KEY `radioid` (`deviceid`)
) ENGINE=InnoDB AUTO_INCREMENT=10647 DEFAULT CHARSET=latin1;