update orders_sub set ors.ors_status='3'
from orders_sub ors inner join returns2 rn on ors.ors_orid=rn.rn_orid
inner join products pd on pd.pd_id=ors.ors_pdid
inner join returns_sub rns on rns.rns_rnid=rn.rn_id
where ors.ors_pdid=rns.rns_pdid and rn.rn_id='27'
update orders_sub ors
inner join returns2 rn on ors.ors_orid=rn.rn_orid
inner join products pd on ors.ors_pdid=pd.pd_id
inner join returns_sub rns on rns.rns_rnid=rn.rn_id and ors.ors_pdid=rns.rns_pdid
set ors.ors_status='3' where rn.rn_id='27'
อาจจะไม่ต้อง join products ถ้า returns_sub.rns_pdid เป็น fk ของ products.pd_id