mysql触发器插入多条记录。我使用的是navicat,不知道怎么写

mysql触发器插入多条记录。我使用的是navicat,不知道怎么写,第1张

MySQL数据库基础与实例教程的课件,涉及到触发器的使用。地址如下:

http://wenku.baidu.com/view/0f08e657ff00bed5b8f31d25.html

我另外给你一段代码,给你参考:

create table organization(

o_no int not null auto_increment,

o_name varchar(32) default '',

primary key (o_no)

) engine=innodb

create table member(

m_no int not null auto_increment,

m_name varchar(32) default '',

o_no int,

primary key (m_no),

constraint organization_member_fk foreign key (o_no) references organization(o_no)

) engine=innodb

insert into organization(o_no, o_name) values

(null, 'o1'),

(null, 'o2')

insert into member(m_no,m_name,o_no) values

(null, 'm1',1),

(null, 'm2',1),

(null, 'm3',1),

(null, 'm4',2),

(null, 'm5',2)

delimiter $$

create trigger organization_delete_before_trigger before delete on organization for each row

begin

delete from member where o_no=old.o_no

end

$$

delimiter

select * from member

delete from organization where o_no=1

select * from member

可以这样:

select count(*)

from t_lesson

where t_lesson.bookId in (

    select id 

    from t_book 

    where t_book.userId=2)

望采纳,谢谢


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/8693861.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-20
下一篇 2023-04-20

发表评论

登录后才能评论

评论列表(0条)

保存