Code: Select all
create trigger login_to_con after insert on login
for each row begin
insert into contact set con_name = new.co_name;
end;Code: Select all
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'insert
into contact set con_name = new.co_name' at line 3Near as I can tell, my code is identical to their example with the exception of table names... any ideas?
If it helps, here are the table definitions:
login:
Code: Select all
+-------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| co_name | varchar(255) | NO | PRI | | |
| pass | varchar(255) | NO | | | |
| admin_email | varchar(255) | NO | | | |
+-------------+--------------+------+-----+---------+-------+Code: Select all
+----------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+------------------+------+-----+---------+-------+
| con_id | int(10) unsigned | NO | PRI | | |
| con_name | varchar(255) | NO | MUL | | |
| email | varchar(255) | YES | | NULL | |
| phone | varchar(15) | YES | | NULL | |
| fax | varchar(15) | YES | | NULL | |
+----------+------------------+------+-----+---------+-------+-Dex
EDIT:
If I can't get this trigger to work, I'm just gonna end up doing the equivalent in PHP. I'd rather have the database take care of it, though.