比如手机号码。我写了就拼接进去,不写就不要这个条件,
这个and phone like "%'${phone}'%"条件怎么写呀,如果直接放空,肯定不好吧。
select * from 表
where 1=1
${if(len(phone)=0,"","and phone like '%"+phone+"%'")}
条件改为这个试试,先判断是否为空,为空不过滤:${IF(LEN(phone)=0,""," and phone like '%"+phone+"%'")}