我有以下从SSRS到MySQL数据库的ODBC查询:
SELECT ID, StartTime, StartTimeMS, EndTime, EndTimeMS, TIMEDIFF(EndTime, StartTime) AS CallDuration, CallType, CallerID, DialedNumber, Extension
FROM `call`
WHERE (CallerID = ?) OR
(Extension = ?) AND (StartTime < ?) AND (StartTime > ?)
当我运行SSRS时,前两个参数会提示两次。理想情况下,我只需输入一次该值即可使用两次。我可以在SSRS查询中使用位置参数两次,以便不会提示用户两次吗?
答案 0 :(得分:0)
命名参数:
SELECT ID, StartTime, StartTimeMS, EndTime, EndTimeMS, TIMEDIFF(EndTime, StartTime) AS CallDuration, CallType, CallerID, DialedNumber, Extension
FROM `call`
WHERE (CallerID = @number) OR
(Extension = @number) AND (StartTime < @EndDate) AND (StartTime > @BeginDate)
答案 1 :(得分:0)
我不认为您可以将命名参数传递给MySQL,但我认为您可以在查询中创建它们:
SET @number = ?
SET @EndDate = ?
SET @BeginDate = ?
SELECT ID, StartTime, StartTimeMS, EndTime, EndTimeMS, TIMEDIFF(EndTime, StartTime) AS CallDuration, CallType, CallerID, DialedNumber, Extension
FROM `call`
WHERE ( (CallerID = @number) OR (Extension = @number) ) AND (StartTime < @EndDate) AND (StartTime > @BeginDate)
我认为您需要将 OR 子句放在一组单独的括号中。