我有这个代码:
SELECT idcallhistory3, callid, starttime, answertime, endtime, duration, is_answ, is_fail, is_compl, is_fromoutside, mediatype, from_no, to_no, callerid, dialednumber, lastcallerid, lastdialednumber, group_no, line_no FROM "public".callhistory3 WHERE (starttime >= ?) AND (endtime <= ?) AND (is_fromoutside = ?) AND (from_no = ?) AND (to_no = ?)
问题是我需要传递一个值吗?并获得所有结果没有过滤器,有些像*
有帮助吗?
WHERE (@start is null OR starttime >= @start) AND (@end is null OR endtime <= @end) AND (@fromOutside is null OR is_fromoutside = @fromOutside) AND (@fromNo is null OR from_no = @fromNo) AND (@toNo is null OR to_no = @toNo)
传递所有参数的空值(dang sql nulls;感谢GC).