说明:mysql在插入数据的时候检查数据的唯一性,符合条件的数据存在的话不插入,不存在的话插入数据,下面是书写示例:
INSERT INTO digital_index_warning_history( monitor_point_name, device_name, param_name, value, warning_type, l_limit, ll_limit, lll_limit, h_limit, hh_limit, hhh_limit, warning_pri, created_at) SELECT #{monitorPointName}, #{deviceName}, #{paramName}, #{value}, #{warningType}, #{lLimit}, #{llLimit}, #{lllLimit}, #{hLimit}, #{hhLimit}, #{hhhLimit}, #{warningPri}, now() FROM dual WHERE NOT EXISTS (SELECT recovered_at FROM digital_index_warning_history WHERE monitor_point_name=#{monitorPointName} AND param_name=#{paramName} AND recovered_at IS NULL )