update packingtask set departcoding = (select p.departcoding from invoiceplan p where p.id = packingtask.sourceid) where tasktype = 0; update packingtask set departcoding = (select p.departCode from recyclingrecord p where p.id = packingtask.sourceid) where tasktype = 1; update packingtask set departcoding = (select p.departCoding from returnGoodsRecord p where p.id = packingtask.sourceid) where tasktype = 2;