I have a trigger and I need to insert the ID from the tracks able into the events table AFTER insert into tracks. I just need to select the ID from tracks, nothing more. The ID in the tracks table has a foreign key to the ID in another table named members. I doubt that is important but just in case. I shouldn’t imagine you need any info on the tables but just ask if you do.
Here is my trigger
delimiter $$
CREATE
TRIGGER tracks_event AFTER INSERT
ON tracks FOR EACH ROW
BEGIN
INSERT into events(ID, action)
VALUES (?, has uploaded a track.);
END$$
delimiter ;
If you want the ID that is in the tracks row being inserted then you can use
NEW.ID. This will give you this ID column of the row that has been inserted.For more trigger examples and a few hints the MySQL reference manual helps (along with being a great reference for syntax etc):
http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html