1

I've a table (hosted in a database SQL Server) where i've products stored. 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).

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.

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

It's returning 0 rows. Is anything wrong in that query?

Thanks

3

3 Answers 3

3
  1. Get rid of the spaces inside the single-quotes.
  2. Append another %.

E.g.:

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. I have edited the question to remove the extraneous spaces.

Sign up to request clarification or add additional context in comments.

2 Comments

The spaces are not really there in Guilherme's question - try selecting the query and pasting it somewhere.
The problem was the other % at the end of. Thanks
3

Try adding another percentage sign at the end as well, in case the last character isn't a semi-colon, i.e:

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

Comments

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

3 Comments

You might end up with false positives with this search. It's better to include at least two '&nbsp;'s, since you know all results will contain that.
The point was to add the second %. Following your logic, why not add 3 &nbsp; instead?
It wasn't really clear what the point was, since you also stripped off the & and ;. Were those also problematic? I don't see a problem in adding 3 &nbsp; - but the OP specified 2 so you could have left it that way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.