MyBatis动态SQL使用,传入参数Map中的Key判断
时间:2021-07-01 10:21:17
帮助过:1人阅读
select id="" parameterType="Map" resultMap="commodityResultMap" >
SELECT c.id c_id,c.variety_id,c.nickName c_nickName,c.description c_description,c.ordinaryPrice c_ordinaryPrice,c.memberPrice c_memberPrice,c.path c_path,v.id v_id,v.nickName v_nickName
FROM commodity c
INNER JOIN variety v
ON c.variety_id=v.id
where 1=1
<!-- _parameter.containsKey(‘键‘) 作用:判断键是否存在返回值boolean #{键}取对应的值 !必须三处键值对应,否则取不到值-->
<if test="_parameter.containsKey(‘varietyID‘)">
and v.id=#{varietyID}
</if>
</select>
MyBatis动态SQL使用,传入参数Map中的Key判断
标签: