A和B两个表
触发器里这样写
update [ICStockBill
set [FHeadSelfB0436]=
(select case count(*) when 0 then '都是0' else '都是85' end
from [ICStockBillEntry]
where [ICStockBillEntry].[FInterID]=(select [FInterID] from inserted) and [FSourceTranType]<>85 group by [FSourceTranType])
where [ICStockBill].[FInterID]=(select [FInterID] from inserted)
A,B两个表里都有FInterID.根据A表里的FInterID查找B表里的FInterID字段,然后再判断FSourceTranType这个字段是不是都是85.
如果都是85就返回 是,否则就返回否.
我这样如果是就返回都是85,如果否就返回的时空值.
大神门帮看看
http://www.cnblogs.com/yuxiaohui/p/3204817.html
触发器我知道怎么写, 我上面写的那个返回的结果是错误的.
首先,你这触发器建的不对
CREATE TRIGGER语法是:
CREATE TRIGGER trigger_name trigger_time trigger_event
ON tbl_name FOR EACH ROW trigger_stmt
参考自:
MySQL触发器(TRIGGER)用法介绍 http://www.data.5helpyou.com/article381.html
其次,你的判断语句写的也不对
CASE的语法是:
CASE value WHEN [compare-value] THEN result [WHEN [compare-value] THEN result ...] [ELSE result] END
CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END
参考自:
MySQL控制流程函数 http://www.data.5helpyou.com/article327.html