0

As i have two tables called buildings and address. i have to insert values to both tables at same time but as column 'id' is auto increment in buildings table after inserting into buildings table 'id' will be generated the same 'id' has to be inserted into 'ref_id' of address table.

so please help me to create triggers for this..

CREATE TABLE `buildings` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`client_id` int(11) NOT NULL,
`sl_no` int(11) NOT NULL,
`name` varchar(50) NOT NULL,
PRIMARY KEY(id,client_id)
)

CREATE TABLE `address` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ref_id` int(11) NOT NULL,
`line1` varchar(100) NOT NULL,
`line2` varchar(100) NOT NULL,
`city` varchar(30) NOT NULL,
`state` varchar(30) NOT NULL,
`pincode` varchar(6) NOT NULL,
PRIMARY KEY(id)
)

0 Answers0