Elitmiar
Elitmiar

Reputation: 36829

Postgres query not returning any rows using the like operator

I have the following query

Select alpha_key,name,trading_as ,typeclient from client_details where upper(trading_as) like '%TEST\\''S LOGISTICS SERVICES%' order by name ;

does not return any rows but

Select alpha_key,name,trading_as ,typeclient from client_details where upper(trading_as) = 'TEST\\''S LOGISTICS SERVICES' order by name ;

returns a row.

Upvotes: 0

Views: 174

Answers (1)

Toto
Toto

Reputation: 91375

You have to escape twice the backslash because there are a double interpretation, one when analizing the string and another one when compare with LIKE.

So your request becomes:

Select alpha_key,name,trading_as ,typeclient 
from client_details 
where upper(trading_as) like '%TEST\\\\''S LOGISTICS SERVICES%' 
order by name ;

Upvotes: 1

Related Questions