表:note
ID  content         num
1    asjdlsdf        0
2    asda sewaeawe   0
3    asdasdasd       0如果select content from note where id=1; 那么 num+1 可以实现吗,在Mysql里触发器好像只对update,insert, delect 有用MySQL

解决方案 »

  1.   

    据我了解,不行,另外,这是sqlserver专区,发到这里将延迟甚至无法解决你的问题。给你一个思路:
    if (select count(1) from note where id=1)>0
    begin
       update note set num=num+1 where id=1
       select content from note where id=1
    end上面的where 中的id=可以写成变量形式,目的就是先检查这个查询是否有数据,有就update,并查询。
      

  2.   

    你想记录访问每个ID的次数?不太好弄,一般像楼上说的,只有在你自定义的存储过程中加逻辑来记录。想用触发器的话,没有SELECT触发器
      

  3.   

    你还是让程序员在程序里面去搞吧,DBA就不是干这事的