[英]SQL Query Search fetch from same table filtering by status
Allright...the Query is, 好吧...查询是
I have a Table: Website_Articles
我有一张桌子:
Website_Articles
The Columns Article, Id, Author, PublishedOn, ArticleName
are common slots used for storing data for different pages. 列
Article, Id, Author, PublishedOn, ArticleName
是用于存储不同页面数据的公共插槽。 it is differentiated by giving a Status ID. 通过提供一个状态ID来区分它。 (eg: attahced pic)
(例如:attahced图片)
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. 我要实现的是使用搜索查询,我只想通过提到的状态ID来过滤来自特定列的结果数据,否则搜索结果不应来自提到的状态ID。 (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
但这带出了
Website_Articles
所有内容
Any assistance would be much appreciated. 任何帮助将不胜感激。 thank you.
谢谢。
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 + '%' ))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.