0
我有以下select語句正在爲我工作。結合多個WHERE子句
select *
from BND_listing right
join BND_ListingCategories on BND_Listing.CatID = BND_ListingCategories.CatID
where
(CategoryName = '[querystring:filter-Category]' or
'[querystring:filter-Category]' = 'All')
and (City = '[querystring:filter-City]' or
'[querystring:filter-City]' = 'All')
and (Region = '[querystring:filter-State]' or
'[querystring:filter-State]' = 'All')
and (Country = '[querystring:filter-Country]' or
'[querystring:filter-Country]' = 'All')
and isnull(Company,'') <> ''
order by
Company asc
除了想它做什麼我包括以下WHERE子句,基本上只允許我創建一個「搜索框」
DECLARE @param VARCHAR(MAX)
SET @param = '[querystring:searchterm]'
SELECT Company
FROM BND_Listing
WHERE Company LIKE '%' + @param + '%'
是否有可能這兩個結合起來選擇一個語句並保留所有功能?
謝謝@tuxmania – UserSN