有三个表 分别是 caution(id、carname)、outbox(phoneid、carname)、phone(id、phoneid、sate)
我想实现的是 在caution这个表建一个触发器, 实现但caution表插入一条数据的时候,插入到outbox表里, 因为phone表
里phoneid有几个,当sate状态为1时,把phoneid的插入到outbox里下面是我建的触发器,不过只能插入一条create trigger insertd
on caution
for insert
as begin
insert into outbox(carname,phoneid)
select carname,(select top 1 phoneid from phone where sate='1') from insertedend
我想实现的是 在caution这个表建一个触发器, 实现但caution表插入一条数据的时候,插入到outbox表里, 因为phone表
里phoneid有几个,当sate状态为1时,把phoneid的插入到outbox里下面是我建的触发器,不过只能插入一条create trigger insertd
on caution
for insert
as begin
insert into outbox(carname,phoneid)
select carname,(select top 1 phoneid from phone where sate='1') from insertedend
FOR INSERT
AS
BEGIN
INSERT INTO outbox ( carname, phoneid )
SELECT carname,
phoneid
FROM inserted
CROSS JOIN phone
WHERE phone.sate = '1' END
on caution
for insert
as begin
insert into outbox(carname,phoneid)
select a.carname,b.phoneid from inserted a ,phone b where b.sate='1'end