I have a column named
varchar type. It contains values like
uvwxyz. A search for
uv-wx-yz does not return those records.
How should I write the query to meet this requirement?
This situation seems to be the result of a bad design decision.
As this column is not storing human readable content, but is to be used as an identifier, the content of this column should have a uniform structure, either with or without the dashes, but not mixing them! You'd also have a hard time having a UNIQUE constraint on this column...
I'd recommend stripping the dashes from the table:
UPDATE table SET parcel_number = replace(parcel_number,'-', '');
Then you only have to strip the dashes from the the search string too. I assume
ab-cd-ef is the same as
abcdef. Do note however that doing so means
ab-cd-ef will be treated as being the same.