0
我有一個GridView將有多個搜索選項。變量搜索查詢
Call Date
Start_Time (between two time values)
Call_Time
AgentID
Phone
他們想要的是所有這些選項都可以通過單個搜索按鈕進行搜索。
我遇到的問題是如何建立查詢是動態的,所以如果他們只搜索一個選項,它將搜索,如果他們通過上述三個搜索它仍然會提供準確的結果。
這裏是查詢至今:
SELECT *, 'file://///server/folder/' + replace(call_date, '/', '') + '/'
+ qa_status + '.vox' as url FROM [JM_NSC_Recordings] WHERE ([areacode] + [phone] = @phone)
Phone = [areacode] + [phone] // @phone
Start Time = between [start_time] and [start_time] @starttime
Call Time = [call_time] // @calltime
AgentID = [tsr] // @agentid
Call Date = [call_date] // @calldate
在數據庫中這些字段的所有都是VARCHAR
當時tryign避免做大量的工作在後面的代碼。能夠找到一個基於SQL的解決方案'WHERE(@phone爲null或[areacode] + [phone] = @phone)' –