0

I have a string: A%A

I want to find all string same start with A%A in database.

Example:

AABCD - false
AABCE - false
AA%BC - true

I use the sql statement:

Select * from Tabel where Column like 'AA%B%'

But the result are:

AABCD
AABCE
AA%BC

Because the string include wildcard '%' and postgres select wrong.

Please suggest me a solution

1

1 Answer 1

2

To escape the % char, use \ like this \%

UPDATE

Another approach can be achieved by using the ESCAPE keyword with empty string after it, this way you tell postgres to disable escaping, and the % becomes a normal char

select * from Table where Column like '%' ESCAPE '';
Sign up to request clarification or add additional context in comments.

Comments

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.