select *
from material_preparation_record mpr
where 1=1
and product_code='${物料编码}'
and product_name='${物料名称}'
and product_spec='${物料规格}'
and ${if(a=1,"batch='" +到货批号+"'","pallet_id='"+托盘id+"'")}
单纯看sql 语法好像没啥问题,具体的你可以在数据集这里模拟一下,写好你查询的参数,然后预览查询的SQL,这样子就知道是 sql写法问题 还是说这个查询条件就是没有数据
select * from material_preparation_record mpr where 1=1 and product_code='${物料编码}' and product_name='${物料名称}' and product_spec='${物料规格}' ${if(a=1,"and batch='" +到货批号+"'","and pallet_id='"+托盘id+"'")}
这个你需要检查传入的参数值了
把日志级别改成debug后再预览,然后去日志里面提取到参数值的SQL.提取到SQL后用数据库管理软件查询看有数据没(可能数据库里面有空格什么的)
你这么写就是必须要把后面的查询条件都写上才能查出来
${if(len(a) = 0,"","and bm = '"+ a +"'")}这样写查询条件可带可不带都能查出来,看你的需求了