select qt.id, qt.chapter_id, qt.type, qt.directory, qt.code, qt.name, qt.dept_id, SUBSTR(qt.directory, 1, INSTR(qt.directory, '.') - 1) as directorySubStr, ct.name as chapter_name from t_questionnaire_template qt left join t_chapter_template ct on qt.chapter_id=ct.id left join sys_dept d on d.dept_id = qt.dept_id select seq_t_questionnaire_template.nextval as id from DUAL insert into t_questionnaire_template id, chapter_id, chapter_id, type, directory, code, name, dept_id, #{id}, #{chapterId}, (select id from t_chapter_template ct where ct.code = #{chapterCode}), #{type}, #{directory}, #{code}, #{name}, #{deptId}, update t_questionnaire_template chapter_id = #{chapterId}, type = #{type}, directory = #{directory}, code = #{code}, name = #{name}, dept_id = #{deptId}, where id = #{id} delete from t_questionnaire_template where id = #{id} delete from t_questionnaire_template where id in #{id}