select qt.id, qt.chapter_id, qt.type, qt.directory, qt.code, qt.name, qt.dept_id, ct.name as chapter_name from t_questionnaire_template qt left join t_chapter_template ct on qt.chapter_id=ct.id insert into t_questionnaire_template chapter_id, type, directory, code, name, dept_id, #{chapterId}, #{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}