SQL语句问题

2 sql dataset

我有这个代码:

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 = ?)
Run Code Online (Sandbox Code Playgroud)

问题是我需要传递一个值吗?并获得所有结果没有过滤器,有些像*

有帮助吗?

小智 7

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)
Run Code Online (Sandbox Code Playgroud)

传递所有参数的空值(dang sql nulls;感谢GC).