<select id="findByConnectorPrice" parameterType="com.hlht.evcs.bean.ConnectorPriceRelation"
resultMap="BaseResultMap">
select
p.customer_operator_id,
p.connector_id,
p.template_id,
p.relate_time,
p.charge_operator_id
from
in_connector_price_relation p
where 1=1
<if test="CustomerOperatorId != null and CustomerOperatorId!=‘‘ ">
and p.customer_operator_id = #{CustomerOperatorId}
</if>
<if test="ConnectorId != null and ConnectorId!=‘‘ ">
and p.connector_id = #{ConnectorId}
</if>
order by ${RelateTime} desc
</select>
<select id="findByConnectorPrice" parameterType="com.hlht.evcs.bean.ConnectorPriceRelation"
resultMap="BaseResultMap">
select
p.customer_operator_id,
p.connector_id,
p.template_id,
p.relate_time,
p.charge_operator_id
from
in_connector_price_relation p
<where>
<if test="CustomerOperatorId != null and CustomerOperatorId!=‘‘ ">
and p.customer_operator_id = #{CustomerOperatorId}
</if>
<if test="ConnectorId != null and ConnectorId!=‘‘ ">
and p.connector_id = #{ConnectorId}
</if>
</where>
order by p.relate_time desc limit 1
</select>
【Mybatis】Mybatis中避免where空条件后面添加1=1 优化方法
原文:https://www.cnblogs.com/Twittery/p/14299132.html