${if(参数1 = '确定',"
select * from 表 where 1=1 ${if(len(参数2) == 0,"","and 字段名 = '" + 参数2 + "'")}
","
sql2
")}
如上语句,是根据参数1的值不同,去执行不同的sql,想要在sql中再加入参数2为空选择全部的过滤,应该怎么写,上面写法报错
${if(参数1 = '确定',"select * from 表 where 1=1"+if(len(参数2) == 0,"","and 字段名 = '" + 参数2 + "'"),"sql2 ")}
select * from table1 where ${参数} = 1 union all select * from table1 where ${参数} = 2