SELECT tg.id, tg.sheep_id, tg.fold_to, tg.fold_from, tg.reason, tg.variety_id, bv.variety AS varietyName, tg.technician, tg.status, tg.comment, tg.create_by, tg.create_time, sf_from.sheepfold_name AS foldFromName, sf_to.sheepfold_name AS foldToName FROM sc_trans_group tg LEFT JOIN da_sheepfold sf_from ON tg.fold_from = sf_from.id LEFT JOIN da_sheepfold sf_to ON tg.fold_to = sf_to.id LEFT JOIN bas_sheep_variety bv ON tg.variety_id = bv.id insert into sc_trans_group sheep_id, fold_to, fold_from, variety_id, reason, technician, status, comment, create_by, create_time, #{sheepId}, #{foldTo}, #{foldFrom}, #{varietyId}, #{reason}, #{technician}, #{status}, #{comment}, #{createBy}, #{createTime}, update sc_trans_group sheep_id = #{sheepId}, fold_to = #{foldTo}, fold_from = #{foldFrom}, variety_id = #{varietyId}, reason = #{reason}, technician = #{technician}, status = #{status}, comment = #{comment}, create_by = #{createBy}, create_time = #{createTime}, where id = #{id} delete from sc_trans_group where tg.id = #{id} delete from sc_trans_group where id in #{id}