select * from table a where a.project_id=#{projectId} and a.id != #{id} and a.status=3 and a.id_card = #{code} or a.unit_code = #{code}
select * from table a where a.project_id=#{projectId} and a.id != #{id} and a.status=3 and
<if test="type == 'idCard'">a.id_card = #{code}</if>
<if test="type == 'unitCode'">a.unit_code = #{code}</if>
<if test="type == idCard">a.id_card = #{code}</if>
<if test="type == unitCode">a.unit_code = #{code}</if>
<if test='type == "idCard"'>a.id_card = #{code}</if>
<if test='type == "unitCode"'>a.unit_code = #{code}</if>
下面的sql是对上面的优化 但是这样写运行时会把错(3种都会badSql) 求大佬解答