📄 favorite.sql
字号:
USE [BookShop]
GO
/****** 对象: Trigger [dbo].[favorite] 脚本日期: 12/14/2008 11:11:14 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
alter trigger [dbo].[favorite]
on [dbo].[OrderContent]
for insert
as
begin
--注:如果favorite没有BookID,就插不进去
if exists
(
select count(*) from Inserted,FavoriteBook
where Inserted.BookID=FavoriteBook.BookID
)
begin
update FavoriteBook
set BookCount=FavoriteBook.BookCount+Inserted.BookCount
from FavoriteBook,Inserted
where Inserted.BookID=FavoriteBook.BookID
end
if not exists
(
select count(*) from Inserted,FavoriteBook
where Inserted.BookID=FavoriteBook.BookID
)
begin
insert into FavoriteBook(BookID,BookCount)
select BookID,BookCount
from Inserted
end
end
select * from FavoriteBook
select * from OrderContent
delete from FavoriteBook
delete from OrderContent
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -