Reputation: 150
Allright...the Query is,
I have a Table: Website_Articles
The Columns Article, Id, Author, PublishedOn, ArticleName
are common slots used for storing data for different pages. it is differentiated by giving a Status ID. (eg: attahced pic)
What i want to achieve is on using the search query, i want to filter the result data only from a specific column by the status ID mentioned or the search result should not come from the status ID mentioned. (both ways is ok)
the command i have right is this....
SELECT SUBSTRING(Article, 0, CHARINDEX(' ', Article, 300)) + '...'
AS Article, Id, Author, PublishedOn, ArticleName
FROM Website_Articles
WHERE (Article LIKE '%' + @Article + '%') or
(ArticleName LIKE '%' + @ArticleName + '%' )
but this brings out everything from Website_Articles
Any assistance would be much appreciated. thank you.
Upvotes: 0
Views: 350
Reputation: 3846
Could this be what you are looking for??
SELECT SUBSTRING(Article, 0, CHARINDEX(' ', Article, 300)) + '...'
AS Article, Id, Author, PublishedOn, ArticleName
FROM Website_Articles
WHERE Status = 'Menu' AND
((Article LIKE '%' + @Article + '%') or
(ArticleName LIKE '%' + @ArticleName + '%' ))
or
SELECT SUBSTRING(Article, 0, CHARINDEX(' ', Article, 300)) + '...'
AS Article, Id, Author, PublishedOn, ArticleName
FROM Website_Articles
WHERE Status <> 'Menu' AND
((Article LIKE '%' + @Article + '%') or
(ArticleName LIKE '%' + @ArticleName + '%' ))
Upvotes: 1