简体   繁体   English

SQL-需要帮助来建立选择查询

[英]SQL - Need help build a select query

I've a table (hosted in a database SQL Server) where i've products stored. 我有一张存储产品的表(托管在SQL Server数据库中)。 The person who inserted a few products last week, instead of making new lines with "Enter" (tinyMCE would created a </br> tag) in description, she had typed "Space" creating white spaces (she though that typing white spaces, creates new line when it goes to the new line. Really dumb). 上周插入了一些产品的人,而不是在描述中使用“ Enter”(tinyMCE将创建一个</br>标签)进行</br>行,而是输入了“ Space”来创建空白(尽管她输入了空白,转到新行时创建新行(真的很愚蠢)。

So, i've records something like this: 因此,我记录了以下内容:

Description: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;

Now i'm trying to create a query for search this records, but i think i'm using LIKE operator in a wrong way. 现在,我正在尝试创建用于搜索此记录的查询,但是我认为我以错误的方式使用了LIKE运算符。

SELECT * From ProductsDescription WHERE Description LIKE '%&nbsp;&nbsp;'

It's returning 0 rows. 它返回0行。 Is anything wrong in that query? 该查询有什么问题吗?

Thanks 谢谢

如果最后一个字符不是分号,请尝试在末尾添加另一个百分号,例如:

SELECT * From ProductsDescription WHERE Description LIKE '%&nbsp;&nbsp;%'
  1. Get rid of the spaces inside the single-quotes. 消除单引号内的空格。
  2. Append another % . 追加另一个%

Eg: 例如:

SELECT * From ProductsDescription WHERE Description LIKE '%&nbsp;&nbsp;%';

Edit: 编辑:
Ignore point #1 above. 忽略上面的第一点。 As @Hippo notes in a comment that was simply a formatting issue. 正如@Hippo在评论中指出的那样,这仅仅是格式问题。 I have edited the question to remove the extraneous spaces. 我已编辑问题以删除多余的空格。

select * from ProductsDescription where description like '%nbsp%'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM