Question: > desc table1; +-------+--------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------+------+-----+---------+----------------+ | id | int(5) | NO |

> desc table1; +-------+--------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------+------+-----+---------+----------------+ | id | int(5) | NO | PRI | NULL | auto_increment | | var | int(5) | YES | | NULL | | +-------+--------+------+-----+---------+----------------+ 2 rows in set (0.00 sec)

> desc table2 -> ; +-------+--------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------+------+-----+---------+----------------+ | id | int(5) | NO | PRI | NULL | auto_increment | | var1 | int(5) | YES | | NULL | | | var2 | int(5) | YES | | NULL | | +-------+--------+------+-----+---------+----------------+ 3 rows in set (0.00 sec)

> DELIMITER $$ > CREATE TRIGGER total BEFORE INSERT ON table2 FOR EACH ROW BEGIN set NEW.var2 = table1.var * new.var1; END$$ Query OK, 0 rows affected (0.11 sec) > DELIMITER ;

]> INSERT INTO table2 (var1) VALUES('5'); ERROR 1109 (42S02): Unknown table 'table1' in field list

How come I cannot insert. I tried many different things, it still cannot insert.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!