S
S
svem2011-02-17 12:43:42
MySQL
svem, 2011-02-17 12:43:42

MySQL and insert trigger

I interpose in the first table record. It also has an “after insert” trigger that adds an id from the first table to the second. How to implement it?

If I interpose in the trigger request: INSERT INTO table2 VALUES (table2.id = LAST_INSERT_ID()); - "1" is added.
If the query is: INSERT INTO table2 VALUES (table2.id = new.id); - "0".

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
carbonariy, 2011-02-17
@svem

Ubuntu 10.01 + MySQL 5.1.49, works fine via

INSERT INTO table2 (id) values (NEW.id);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question