1. 程式人生 > 其它 >帆軟引數為空查詢全部

帆軟引數為空查詢全部

引數為空查詢全部:
固定值
WHERE 1=1 ${if(len(引數) == 0,"",“and 欄位 = '” + 引數 + “’”)}
模糊查詢
WHERE 1=1 ${if(len(引數) == 0,""," and 欄位like ‘%" + 引數 + "%’")}
下拉複選框
WHERE 1=1 ${if(len(引數) == 0,"",“and 欄位 in (’” + 引數+ “’)”)}
WHERE 1=1 ${if(len(引數) == 0 ,"" , " and 欄位 in (’" + SUBSTITUTE(引數,",","’,’") + “’)”)}
單選框
${if(len(引數) == 0 ,"" , " and 欄位 in (" + SUBSTITUTE(引數,",",",") + “)”)}
時間:t.ordertime between ‘ begindate′andtochar (todate( ′ {begindate}' and to_char(to_date(' begindate′andtoc​har(tod​ate(′{enddate}’,‘yyyy-mm-dd’),‘yyyy-mm-dd’)
${if(len(trim(storename))==0,"",“and t.storename in (’”+trim(storename)+"’) ")}

between…and…如果想對日期進行處理可拆分開來寫
${if(len(trim(begindate1))==0,"",“and substr(o.booktime,0,10) >= (’”+trim(begindate1)+"’) “)} ${if(len(trim(enddate1))==0,”",“and substr(o.booktime,0,10) <= (’”+trim(enddate1)+"’) ")}