update a set aid3='003'
from 表a a,(
select distinct aid1,aid2 from 表b b
where not exists(
select * from 表b
where aid1=b.aid1 and aid2=b.aid1
and bid2<>'003')
)b where a.aid1=b.aid1 and a.aid2=b.aid1
from 表a a,(
select distinct aid1,aid2 from 表b b
where not exists(
select * from 表b
where aid1=b.aid1 and aid2=b.aid1
and bid2<>'003')
)b where a.aid1=b.aid1 and a.aid2=b.aid1
from a (
select distinct aid1,aid2 from b
where not exists(
select * from b
where aid1=b.aid1 and aid2=b.aid2
and bid2<>'003')
)b where a.aid1=b.aid1 and a.aid2=b.aid2
from a ,b
where not exists(select 1 from b
where a.aid1=b.aid1
and a.aid2=b.aid2
and b.aid3<>'003'
)