好吧......查询是,
我有一张表:Website_Articles
列Article, Id, Author, PublishedOn, ArticleName
是用于存储不同页面的数据的公共槽。它通过提供状态ID来区分。 (例如:获得图片)
我想要实现的是使用搜索查询,我想通过提到的状态ID仅从特定列过滤结果数据,或者搜索结果不应来自提到的状态ID。 (两种方式都可以)
我拥有的命令就是这个....
SELECT SUBSTRING(Article, 0, CHARINDEX(' ', Article, 300)) + '...'
AS Article, Id, Author, PublishedOn, ArticleName
FROM Website_Articles
WHERE (Article LIKE '%' + @Article + '%') or
(ArticleName LIKE '%' + @ArticleName + '%' )
但这会带来Website_Articles
非常感谢任何帮助。 谢谢。
答案 0 :(得分:1)
这可能是你想要的吗?
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 + '%' ))
或
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 + '%' ))