where1=1

image.png

select * from DY_MYJF_LTHM

where prr_caller_phone like '${caller_phone}%' and 

date_format(prr_date,'%Y-%m-%d') between '${days_e}' and '${days_d}' 

AND prr_called_phone like '${called_phone}%' 

and tl2 in ('${tl}');

数据集查询这样写,现在问题是如果我参数面板上任何一个控件不选或者不填时,依旧可以查询出来数据,应该怎么做? 请教大佬们image.png

FineReport 新用户胖虎是女生 发布于 2025-1-8 11:41 (编辑于 2025-1-8 11:50)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
1
Z4u3z1Lv6专家互助
发布于2025-1-8 11:42(编辑于 2025-1-8 11:56)

类似

image.png

---------

https://help.fanruan.com/finereport10.0/doc-view-4476.html 参考文档

---------

写不来就把SQL粘贴出来 不要截图(我们也懒~)

select * from DY_MYJF_LTHM

where 1=1 ${if(len(caller_phone)==0,""," and prr_caller_phone like '"+caller_phone+"%'")} 

${if(len(days_e)==0,""," AND date_format(prr_date,'%Y-%m-%d')>='"+days_e+"'")}

${if(len(days_d)==0,""," AND date_format(prr_date,'%Y-%m-%d')<='"+days_d+"'")}

${if(len(called_phone)==0,"","AND prr_called_phone like '"+called_phone+"%'")}

${if(len(tl)==0,"","and tl2 in ('"+tl+"')")}

最佳回答
0
snrtuemcLv8专家互助
发布于2025-1-8 11:43
  • 2关注人数
  • 47浏览人数
  • 最后回答于:2025-1-8 11:56
    请选择关闭问题的原因
    确定 取消
    返回顶部