使用sql语句动态拼接where条件,条件中包含 or
select * from dict where 单位编码 IN ('10206') and ver='510' and substr(日期, 1, 7) between '2016-01' and '2035-12' and formula_id='首发集团合并快报' OR ( 单位编码 IN ('10210') and ver='510' and substr(日期, 1, 7) between '2016-01' and '2035-12' and formula_id='首发集团合并快报')
where 后面的筛选条件需要通过sql查询数据表获得,怎么将SQL拼接到where 后面
你写了一大堆,不就等价于
select * from dict where 单位编码 IN ('10206','10210') and ver='510' and substr(日期, 1, 7) between '2016-01' and '2035-12' and formula_id='首发集团合并快报'
吗,为啥重复的条件写了一遍又一遍
已经有配置表了,为何不直接两个表关联查询?,非得把值查出来去拼动态sql?