SELECT a.*
FROM `reciboslinhas01` as a left join documento_d2 as b on b.no_doc=a.n_doc and a.tp=2
where  a.serdoc='A' and b.serdoc='B'
#a.serdoc<>b.serdoc
order by idx desc
limit 10

update 
reciboslinhas01 as a ,documento_d2 as b 
set a.serdoc=b.serdoc
where a.tp=2 and a.n_doc='A' and b.serdoc='B' and b.no_doc=a.n_doc 
;


reciboslinhas01 as a ,documento_d3 as b 
set a.serdoc='B'
where a.tp=3 and a.serdoc='A' and b.serdoc='B' and b.no_doc=a.n_doc 
;