select*from a
where $if{}
想实现,b=='3' 显示全部
b=='4' n_id=参数id
b=='5' n_sjid=参数id
怎样写if?
试试:
select * from a
where 1=1
${if(b='3',"",if(b='4',"and n_id = '"+参数id+"'","and n_sjid = '"+参数id+"'"))}
这个b是参数?参数id,合起来有两个参数吗?
where
1=1
${
switch(b,"3", "",
"4","and n_id='"+参数id+"' ",
"5","and n_sjid='"+参数id+"' "
)
}
多个值判断 switch清楚一点