MySQL trigger on insert


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
4 views
Insert into the first table entry. It also hangs a trigger "after insert", which adds the id from the first table into the second. How to implement it?

If you insert in the trigger query: INSERT INTO table2 VALUES (table2.id = LAST_INSERT_ID()); — add "1".
If the query is: INSERT INTO table2 VALUES (table2.id = new.id); — "0".
by | 4 views

1 Answer

0 like 0 dislike
Ubuntu 10.01 + MySQL 5.1.49, works normally
\r
INSERT INTO table2 (id) values (NEW.id);
by

Related questions

0 like 0 dislike
1 answer
asked Jun 6, 2019 by vladislav997
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked May 4, 2019 by Deka007
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
28,009 users