SQL更新表,请大师指点!谢谢

有一视图v_ware(wareid counter busno name unit)
busno counter wareid name unit
01 A54 02135 百合 克
01 null 05166 黄芪 克
01 NULL 05566 百合 克
01 A54 05421 百合 克
..............

视图中有counter为NULL值 的,例如百合 有同名,且 wareid=02135 的counter是
有值的,那么wareid=05566 的NULL值要求修改为等于 wareid 02135的counter值A54
名称为黄芪的counter值尽管为NULL但是没有同名字的则不需要改变

/*从视图里面提取数据*/
select distinct counter,name into @counter,@name
from v_ware
where counter is not null and counter <> 'null'
limit 1;

select @counter,@name;

/*更新数据*/
update ware set counter=@counter where name = @name;

select * from ware;


你要这个视图对应的sql 贴出来,否则没法更新表