POSTGRES - combine LIKE with exception(E') literal

Viewed 121

I'm trying to match a certain text that includes a single quote (i.e. 'company's report...') normally I would have used the E' literal + ' or double single quotes. but when it gets to using the LIKE '%' operator, things got complicated. what is the best approach to match a text with a single quote?

2 Answers

You can use Dollar-quoted String Constants at Lexical Structure

Your condition should be something like below;

select * from atable
where afield like $$Dianne's %$$
Related