create view myview1
as
select a.*,f_statues=case when f_count<=f_finishcount then '1' else '0' end
from t_order a join t_orderitem b on a.f_id=b.f_orderid
as
select a.*,f_statues=case when f_count<=f_finishcount then '1' else '0' end
from t_order a join t_orderitem b on a.f_id=b.f_orderid
创建一个insert触发器
循环判断f_count<= f_finishcount
把结果更新到视图中创建一个update触发器
循环判断f_count<= f_finishcount
把结果更新到视图中希望听听大家的高见
as
select a.*, f_statues = case when not exists (
select 1 from t_orderitem
where f_orderid = a.f_id and f_count <= f_finishcount
) then 0 else 1 end
from t_order a
create view myview1
as
select a.*, f_statues = case when not exists (
select 1
from t_orderitem
where f_orderid = a.f_id and f_count >= f_finishcount
) then 1 else 0 end
from t_order a
向zarge(鲨猩)学习这个方法好
as
select a.* ,(case when b.f_count-b.f_finishcount>0 then 0 else 1 end ) as f_stutas
from t_order a, t_orderitem b
where a.f_id=b.f_orderid
我觉得是下面这样比较好
create view v_orderitem
as
select t_order.*,status=case when t_order.f_id in
(select distinct a.f_id
from t_order a,t_orderitem c
where c.f_orderid=a.f_id and not exists
(select * from t_orderitem b
where b.f_orderid=a.f_id and b.f_count>f_finishcount
)) then 1 else 0 end
from T_order
在这个视图中,你要注意细表的f_finishcounth和f_count字段不能为空