表tab_user
id name say
1 张三 你好
2 李四 你也好
3 张三 dfdfdf
4 王五 dfdfdfd
5 李四 fdfdfdfd表:tab_count
id name count
tab_user表里的记录是随时在增加的
统计name字段同一名称(比如所有为"张三"的)的记录总数写入到tab_count表里求这样的触发器,不明白的发言!
谢谢!50分送上,谢谢!分不多了,名们兄弟帮忙!
id name say
1 张三 你好
2 李四 你也好
3 张三 dfdfdf
4 王五 dfdfdfd
5 李四 fdfdfdfd表:tab_count
id name count
tab_user表里的记录是随时在增加的
统计name字段同一名称(比如所有为"张三"的)的记录总数写入到tab_count表里求这样的触发器,不明白的发言!
谢谢!50分送上,谢谢!分不多了,名们兄弟帮忙!
解决方案 »
- .Net通过模版生成Word 和Excel下载 部署到IIS报错
- 求类似qq但是web的网页聊天代码!
- 这个是啥意思:this.style.behavior='url(#default#homepage)
- 请教高手在VS2005中ASP.NET里面的"GridView"控件,如何使用?怎么样实现对数据的查询,添加,删除和修改~
- 超简易留言薄 附数据库连接类,分页类。跟大家交流一下
- 如何把RectangleF转换为Rectangle???高手请进!!
- 急~~~css 如何让table里的数据横向显示,并且实现分页
- 用chart control花个pie
- 为什么传过去的参数会少了一个字?
- easyui treegrid 分页栏里的总行数显示不正确
- 关于数据库的使用
- 字符串格式问题,回者有分
insert into tab_count(name,count) values
select name,count(*) from tab_user
group by name
FOR INSERT
AS
Declare @id as varchar(10)
Declare @name as varchar(10)
select @id=id from inserted
select @name = name from inserted
if IF exists(select * from tab_count where id = @id)
begin
update tab_count set tab_count.count=(select count(*) from tab_user where id=@id)
where id=@id
End
else
begin
INSERT INTO tab_count(id,name,count) value (@id,@name,1)
end
如果批量插入你的过程就会出错,可惜结贴了