想要用一个参数控制sql查询语句的where条件,当传入的参数为1是where后面加条件一,参数为2时where后面加条件二目前sql语句写好了,想问一下在dao层如何修改原先的sql语句会用到两个string类参数,现在加一个string类名为type来控制调用哪个条件type的值我想在dao层调用这个语句时自己确定这要怎么写来传参
收起
<select id="selectByType" resultType="com.example.xxx.test"> select * from test where 1=1 <if test="type!= null and type!='' and type== 1"> and xxx1=xxxx1 </if> <if test="type!= null and type!='' and type== 2"> and xxx2=xxxx2 </if> </select>
报告相同问题?