Help Needed for MySQL syntax
Date: 05/03/05
(MySQL Communtiy) Keywords: mysql, sql
Hi everyone,
I performed the following query to implement triggers. But error code 1064 occured.
create table distance(
edge_id varchar(20) NOT NULL,
source_node varchar(20),
dest_node varchar(20),
distance float(9,2),
parent_edge_id varchar(20),
road_condition int,
congestion1 int,
congestion2 int,
congestion3 int,
primary key(edge_id)
);
create table weight(
edge_id varchar(20) NOT NULL REFERENCES distance(edge_id),
weight1 float(9,2),
weight2 float(9,2),
weight3 float(9,2),
primary key(edge_id)
);
My Aim is to automatically insert rows into the weight table, upon insertion of any row in distance table.
So, I wrote the followin syntax:
create TRIGGER calculate
AFTER INSERT ON distance
INSERT INTO weight values(NEW.edge_id,NEW.congestion1,NEW.congestion2,NEW.congestion3);
Is the syntax correct for creating triggers? If it's not so, then please someone tell how to create triggers in MySQL...
Source: http://www.livejournal.com/community/mysql/55572.html