Mysql A new value-added table, the table also add B

New Table c1

CREATE TABLE c1 (id int(11) NOT NULL auto_increment PRIMARY KEY,kl VARCHAR(255))

Inserting data into the table c1

INSERT INTO c1 (kl) VALUES ( 'Li'), ( 'week'), ( 'king'), ( 'Zhao')

New Table c2

CREATE TABLE c2 (id int(11) NOT NULL auto_increment PRIMARY KEY,kl VARCHAR(255))

Inserting data into a table c2

INSERT INTO c2(kl) VALUES('1'),('1'),('1'),('1')

Create new value-added table trigger c1, c2 same table to add value

create trigger c1_insert_c2 after INSERT
on c1 for each ROW
BEGIN
insert into c2(kl) VALUES(new.kl);
END

C1 new value to the table, and query the value of c1 and c2 of

insert into c1 (kl) VALUES('韩')
select * from c1;
select * from c2;

image.pngimage.png

Guess you like

Origin blog.51cto.com/11728495/2485349