GWP
GWP

Reputation: 451

Search for a field that contains ampersand mark

I have a field that contains values such as

fish & chips

When I try to search for this field

Select * From Menu WHERE FoodItem = 'fish & chips'

It returns nothing despite all the matching entries in the table.

Now I realised this is an issue with the ampersand(&) mark. One workaround would be to change all 'fish & chips' to 'fish and chips'. But I would rather not play with that many data.

Also, I don't want to use LIKE or CONTAINS because I want to match things exactly.

How can I write a WHERE statement that will work with the & mark?

Thanks! Cheers!

Upvotes: 0

Views: 1082

Answers (1)

Brien Foss
Brien Foss

Reputation: 3367

Some information is missing. It simply just works given the description of information provided unless you've got a trigger or something that is stripping the & on INSERT or UPDATE.

Verify that the data in the table actually still contains the &.

For example, as you can see here, searching on that character in your string is returning as it should.

Upvotes: 1

Related Questions