educasag
educasag

Reputation: 25

How to use LIKE operator in Oracle SQL

I'm using Oracle and I'm trying to filter part of the text of a string. For example, I want to get when in a text there is 'Credit Note' what happens is that there are values like "Generate Credit Note Manually".

In SQL Server I know it works using:

Select Column1
From Table1
Where Column1 LIKE '% Credit% Note%'

But I don't get the above in Oracle, does not return any match with "Generate Credit Note Manually".

Any suggestions?

Upvotes: 1

Views: 1528

Answers (3)

EverCode
EverCode

Reputation: 66

The syntax you're using is correct.

If the query isn't returning the data there might be something wrong with the data. I know it might look like plain text but sometimes there are invisible encoding along with it, especially if it was copy-pasted from a heavy word processor like MS Word or something.

Create additional rows and write the text manually to make sure there are no encoding being copied. Also, try copy-pasting the value from the table into notepad, see it pastes some additional symbols. Also, check to see if it's a case-sensitivity issue.

Upvotes: 3

rabbithole
rabbithole

Reputation: 11

SELECT Column1
From Table1
Where Column1 LIKE '%Credit Note%'

You don't have to add % to represent the white space. The like operator can take in string and white spaces when you wrap them up in this way 'text to search'.

Upvotes: 0

Daler Khabibov
Daler Khabibov

Reputation: 25

You can use this:

Select Column1 
From Table1 
Where Column1 LIKE '%Credit%'  
  or Column1 LIKE '%Note%'

If you need matching these words together try to use REGEXP_LIKE()

Upvotes: 0

Related Questions