日期:2014-05-17 浏览次数:20784 次
SELECT QuestionParentDirection ,
QuestionChildDirection ,
QuestionStyle ,
QuestionTitle ,
QuestionAnswer ,
SourceCompany ,
QuestionDate
FROM Question
WHERE ( Visibility = 1 )
AND ( @QuestionParentDirection IS NULL
OR RTRIM(QuestionParentDirection) = @QuestionParentDirection
)
AND ( @QuestionChildDirection IS NULL
OR RTRIM(QuestionChildDirection) = @QuestionChildDirection
)
AND ( @QuestionStyle IS NULL
OR RTRIM(QuestionStyle) = @QuestionStyle
)
AND ( @KeyWord IS NULL
OR ( RTRIM(QuestionAnswer) LIKE '%' + @KeyWord + '%'
OR RTRIM(QuestionTitle) LIKE '%' + @KeyWord + '%'
)
)
AND ( @SourceCompany IS NULL
OR RTRIM(SourceCompany) = @SourceCompany
)
AND ( QuestionDate BETWEEN @QuestionDateA
AND @QuestionDateB )
------解决方案--------------------
从最内部的联接查询,或者说从最初的联接查询开始,一步一步看是否有数据。