In my database I have to filter records where name ends with -N,
but when I make the WHERE clause like in the following query it returns me no records, because - is a wild card character.
I am using this query in Oracle database:
select * from product where productname like '%-N'
but the database has records that end with this product name
At first I thought that Oracle allows to specify a range [a-z] in the LIKE operator, and that needs to treat - in a special way. So, my suggestion was to escape the dash:
select * from product where productname like '%\-N' ESCAPE '\'
https://docs.oracle.com/cd/B13789_01/server.101/b10759/conditions016.htm
On the other hand, as @Amadan correctly said in the comment, Oracle's LIKE operator only recognises two wildcard characters: _ and %.
It means that escaping the - should not change anything.
Which means that most likely the dash symbol in the query is not the same dash symbol that you have in your table. There are many-many-many different dashes and hyphens in unicode. Here are the most common. Hyphen-Minus (0x002D), En-Dash (0x2013, Alt+0150), Em-Dash (0x2014, Alt+0151).
- – —
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With